Advertisement
Sungmingamerpro13

DeathScreen with Money and Coins (LocalScript)

Mar 23rd, 2024
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 2.07 KB | None | 0 0
  1. local TweenService = game:GetService("TweenService")
  2. local MarketplaceService = game:GetService("MarketplaceService")
  3. local TeleportService = game:GetService("TeleportService")
  4. local player = game.Players.LocalPlayer
  5.  
  6. -- THIS ARE THE REMOTES YOU NEED TO HAVE INSIDE REPLICATED STORAGE
  7. local diedEvent = game.ReplicatedStorage.DiedEvent
  8. local reviveEvent = game.ReplicatedStorage.reviveEvent
  9. local boughtLifeEvent = game.ReplicatedStorage.boughtLifeEvent
  10. --
  11.  
  12. local ScreenGui = player.PlayerGui.DeathScreen
  13. local extra_life = false
  14.  
  15. local LobbyId = 14705679998
  16. local ProductId = 1773114333
  17.  
  18. local function teleportToLobby()
  19.     TeleportService:Teleport(LobbyId) -- change to lobby ID
  20. end
  21.  
  22. local function startTimer()
  23.     local timer = 30
  24.     repeat
  25.         timer = timer - 1
  26.         ScreenGui.DeathFrame.DiedFrame.Time.Text = "Teleporting In "..timer.." Seconds"
  27.         wait(1)
  28.     until timer <= 0 or extra_life == true
  29.     if extra_life == true then
  30.         reviveEvent:FireServer()
  31.         ScreenGui.DeathFrame.Visible = false
  32.     else
  33.         teleportToLobby()  
  34.     end
  35. end
  36.  
  37. boughtLifeEvent.OnClientEvent:Connect(function()
  38.     extra_life = true
  39. end)
  40.  
  41. ScreenGui.DeathFrame.DiedFrame.Continue.MouseButton1Down:connect(function()
  42.     if player.Coins.Value >= 100 then
  43.         player.Coins.Value = player.Coins.Value - 100
  44.         reviveEvent:FireServer(player)
  45.     elseif player.Money.Value >= 25 then
  46.         player.Money.Value = player.Money.Value - 25
  47.         reviveEvent:FireServer(player)
  48.     else
  49.         MarketplaceService:PromptProductPurchase(player, ProductId)
  50.     end
  51. end)
  52.  
  53. diedEvent.OnClientEvent:Connect(function()
  54.     ScreenGui.DeathFrame.Visible = true
  55.     startTimer()
  56. end)
  57.  
  58. player:WaitForChild("Coins").Changed:Connect(function(Value)
  59.     ScreenGui.DeathFrame.DiedFrame.CoinsAmount.Text = "You Have: "..Value
  60. end)
  61.  
  62. ScreenGui.DeathFrame.DiedFrame.CoinsAmount.Text = "You Have: "..player.Coins.Value.." (Coins)"
  63.  
  64. player:WaitForChild("Money").Changed:Connect(function(Value)
  65.     ScreenGui.DeathFrame.DiedFrame.CashAmount.Text = "You Have: "..Value
  66. end)
  67.  
  68. ScreenGui.DeathFrame.DiedFrame.CashAmount.Text = "You Have: "..player.Money.Value.." (Cash)"
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement