Advertisement
Zuklim65

Idk

Feb 22nd, 2025
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local userInputService = game:GetService("UserInputService")
  3.  
  4. -- Ensure GUI persists after death
  5. local screenGui = Instance.new("ScreenGui")
  6. screenGui.ResetOnSpawn = false -- GUI will not reset on death
  7. screenGui.Parent = player:WaitForChild("PlayerGui")
  8.  
  9. local button = Instance.new("TextButton")
  10. button.Size = UDim2.new(0.3, 0, 0.15, 0)
  11. button.Position = UDim2.new(0.35, 0, 0.75, 0)
  12. button.Text = "Tap to Survive!"
  13. button.TextScaled = true
  14. button.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  15. button.Draggable = true -- Make the button draggable
  16. button.Active = true -- Required for dragging
  17. button.Parent = screenGui
  18.  
  19. local timerLabel = Instance.new("TextLabel")
  20. timerLabel.Size = UDim2.new(0.2, 0, 0.1, 0)
  21. timerLabel.Position = UDim2.new(0.4, 0, 0.1, 0)
  22. timerLabel.Text = "Time: 5"
  23. timerLabel.TextScaled = true
  24. timerLabel.BackgroundTransparency = 1
  25. timerLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  26. timerLabel.Parent = screenGui
  27.  
  28. local clickCount = 0
  29. local requiredClicks = 10
  30. local isGameOver = false
  31. local timeLeft = 5
  32. local waitingForJump = false
  33.  
  34. -- Function to make the player explode
  35. local function explodePlayer()
  36. if player.Character then
  37. local character = player.Character
  38. local explosion = Instance.new("Explosion")
  39. explosion.Position = character:GetPrimaryPartCFrame().p
  40. explosion.Parent = workspace
  41. wait(0.2)
  42. character:BreakJoints() -- Respawn the player
  43. end
  44. end
  45.  
  46. -- Timer function
  47. local function startTimer()
  48. timeLeft = 5
  49. while timeLeft > 0 and not isGameOver do
  50. timerLabel.Text = "Time: " .. timeLeft
  51. wait(1)
  52. timeLeft = timeLeft - 1
  53. end
  54. if not isGameOver then
  55. timerLabel.Text = "BOOM! Jump to Restart!"
  56. explodePlayer() -- Player explodes when time reaches 0
  57. waitingForJump = true -- Must jump to restart
  58. end
  59. end
  60.  
  61. -- Start timer when the game begins
  62. task.spawn(startTimer)
  63.  
  64. local function onButtonClick()
  65. if isGameOver then return end
  66.  
  67. clickCount = clickCount + 1
  68. button.Text = "Taps: " .. clickCount .. "/" .. requiredClicks
  69.  
  70. -- Check if player won
  71. if clickCount >= requiredClicks then
  72. isGameOver = true
  73. waitingForJump = true
  74. button.Text = "You Survived!"
  75. button.BackgroundColor3 = Color3.fromRGB(0, 255, 0) -- Green for success
  76. timerLabel.Text = "Jump to Restart!"
  77. end
  78. end
  79.  
  80. -- Detect player jump to restart game (Mobile & PC)
  81. userInputService.JumpRequest:Connect(function()
  82. if waitingForJump then
  83. -- Reset the game
  84. clickCount = 0
  85. isGameOver = false
  86. waitingForJump = false
  87. button.Text = "Tap to Survive!"
  88. button.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  89. timerLabel.Text = "Time: 5"
  90. startTimer()
  91. end
  92. end)
  93.  
  94. button.MouseButton1Click:Connect(onButtonClick)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement