Hiojojwr

Untitled

Aug 7th, 2025
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.01 KB | None | 0 0
  1.  
  2. local Players = game:GetService("Players")
  3. local Checkpoints = workspace:WaitForChild("Checkpoints"):GetChildren()
  4. local spawnPart = workspace:WaitForChild("SpawnLocation")
  5. local stageCount = #Checkpoints
  6.  
  7. table.sort(Checkpoints, function(a,b)
  8. return tonumber(a.Name) < tonumber(b.Name)
  9. end)
  10.  
  11.  
  12. local function getCheckpoint(stage)
  13. for _, checkpoint in ipairs(Checkpoints) do
  14. if tonumber(checkpoint.Name) == stage then
  15. return checkpoint
  16. end
  17. end
  18. return spawnPart
  19. end
  20.  
  21.  
  22. local DataStoreService = game:GetService("DataStoreService")
  23. local stageData = DataStoreService:GetDataStore("StageData")
  24.  
  25. Players.PlayerAdded:Connect(function(player)
  26. local leaderstats = Instance.new("Folder", player)
  27. leaderstats.Name = "leaderstats"
  28. local stage = Instance.new("IntValue", leaderstats)
  29. stage.Name = "Stage"
  30.  
  31. local savedStage = stageData:GetAsync(player.UserId)
  32. if savedStage then
  33. stage.Value = savedStage
  34. else
  35. stage.Value = 1
  36. end
  37.  
  38. player.CharacterAdded:Connect(function(char)
  39. wait(0.5)
  40. local checkpoint = getCheckpoint(stage.Value)
  41. if checkpoint then
  42. char:MoveTo(checkpoint.Position + Vector3.new(0, 5, 0))
  43. end
  44.  
  45.  
  46. local root = char:WaitForChild("HumanoidRootPart")
  47. while char.Parent do
  48. wait(0.5)
  49. if root.Position.Y < -20 then
  50. char:MoveTo(getCheckpoint(stage.Value).Position + Vector3.new(0, 5, 0))
  51. end
  52. end
  53. end)
  54. end)
  55.  
  56.  
  57. Players.PlayerRemoving:Connect(function(player)
  58. local stage = player:FindFirstChild("leaderstats"):FindFirstChild("Stage")
  59. if stage then
  60. stageData:SetAsync(player.UserId, stage.Value)
  61. end
  62. end)
  63.  
  64. -----------------------------------------------------
  65.  
  66.  
  67. local checkpointPart = script.Parent
  68.  
  69. checkpointPart.Touched:Connect(function(hit)
  70. local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  71. if player then
  72. local stage = tonumber(checkpointPart.Name)
  73. local current = player:FindFirstChild("leaderstats"):FindFirstChild("Stage")
  74. if stage and current and stage > current.Value then
  75. current.Value = stage
  76. end
  77. end
  78. end)
  79.  
  80. -----------------------------------------------------
  81.  
  82.  
  83. local player = game.Players.LocalPlayer
  84. local gui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
  85. local stageText = Instance.new("TextLabel", gui)
  86.  
  87. gui.Name = "StageUI"
  88. stageText.Size = UDim2.new(0, 200, 0, 50)
  89. stageText.Position = UDim2.new(0, 20, 0, 20)
  90. stageText.BackgroundTransparency = 0.3
  91. stageText.BackgroundColor3 = Color3.fromRGB(0,0,0)
  92. stageText.TextColor3 = Color3.new(1,1,1)
  93. stageText.TextScaled = true
  94. stageText.Font = Enum.Font.GothamBold
  95.  
  96. local function update()
  97. while true do
  98. local stat = player:WaitForChild("leaderstats"):WaitForChild("Stage")
  99. stageText.Text = "Stage: "..stat.Value.." / "..stageCount
  100. wait(0.5)
  101. end
  102. end
  103. spawn(update)
  104.  
  105. -----------------------------------------------------
  106.  
  107.  
  108. local finishPart = script.Parent
  109.  
  110. finishPart.Touched:Connect(function(hit)
  111. local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  112. if player then
  113. local stat = player:FindFirstChild("leaderstats"):FindFirstChild("Stage")
  114. if stat and stat.Value == stageCount then
  115. player:Kick("🎉 Congratulations! You finished the obby.")
  116. end
  117. end
  118. end)
  119.  
  120. local Players = game:GetService("Players")
  121. local DSS = game:GetService("DataStoreService")
  122. local stageData = DSS:GetDataStore("StageSave")
  123. local Checkpoints = workspace:WaitForChild("Checkpoints"):GetChildren()
  124. table.sort(Checkpoints, function(a, b) return tonumber(a.Name) < tonumber(b.Name) end)
  125.  
  126. local function getCheckpoint(stage)
  127. for _, c in ipairs(Checkpoints) do
  128. if tonumber(c.Name) == stage then return c end
  129. end
  130. return workspace:WaitForChild("SpawnLocation")
  131. end
  132.  
  133. Players.PlayerAdded:Connect(function(player)
  134. local stats = Instance.new("Folder", player)
  135. stats.Name = "leaderstats"
  136. local stage = Instance.new("IntValue", stats)
  137. stage.Name = "Stage"
  138. stage.Value = stageData:GetAsync(player.UserId) or 1
  139.  
  140. player.CharacterAdded:Connect(function(char)
  141. task.wait(0.5)
  142. local pos = getCheckpoint(stage.Value).Position + Vector3.new(0,3,0)
  143. char:MoveTo(pos)
  144.  
  145. local hrp = char:WaitForChild("HumanoidRootPart")
  146. while char.Parent do
  147. task.wait(0.5)
  148. if hrp.Position.Y < -20 then
  149. char:MoveTo(getCheckpoint(stage.Value).Position + Vector3.new(0,3,0))
  150. end
  151. end
  152. end)
  153. end)
  154.  
  155. Players.PlayerRemoving:Connect(function(player)
  156. local stage = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Stage")
  157. if stage then
  158. stageData:SetAsync(player.UserId, stage.Value)
  159. end
  160. end)
  161.  
  162. ---------------------------------------------------------------
  163.  
  164. local checkpoint = script.Parent
  165. checkpoint.Touched:Connect(function(hit)
  166. local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  167. if player then
  168. local s = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Stage")
  169. if s and tonumber(checkpoint.Name) > s.Value then
  170. s.Value = tonumber(checkpoint.Name)
  171. local sound = checkpoint:FindFirstChild("Sound")
  172. if sound then sound:Play() end
  173. end
  174. end
  175. end)
  176.  
  177. ---------------------------------------------------------------
  178.  
  179. local player = game.Players.LocalPlayer
  180. local gui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
  181. gui.Name = "ObbyUI"
  182.  
  183. local stageLabel = Instance.new("TextLabel", gui)
  184. stageLabel.Size = UDim2.new(0, 200, 0, 40)
  185. stageLabel.Position = UDim2.new(0, 20, 0, 20)
  186. stageLabel.BackgroundColor3 = Color3.new(0,0,0)
  187. stageLabel.TextColor3 = Color3.new(1,1,1)
  188. stageLabel.TextScaled = true
  189. stageLabel.Text = "Stage: ?"
  190. stageLabel.Font = Enum.Font.GothamBold
  191.  
  192. local timerLabel = Instance.new("TextLabel", gui)
  193. timerLabel.Size = UDim2.new(0, 200, 0, 40)
  194. timerLabel.Position = UDim2.new(0, 20, 0, 70)
  195. timerLabel.BackgroundColor3 = Color3.new(0,0,0)
  196. timerLabel.TextColor3 = Color3.new(1,1,1)
  197. timerLabel.TextScaled = true
  198. timerLabel.Text = "Time: 0s"
  199. timerLabel.Font = Enum.Font.GothamBold
  200.  
  201. local time = 0
  202. spawn(function()
  203. while true do
  204. wait(1)
  205. time += 1
  206. timerLabel.Text = "Time: "..time.."s"
  207. end
  208. end)
  209.  
  210. spawn(function()
  211. while true do
  212. wait(0.5)
  213. local s = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Stage")
  214. if s then
  215. stageLabel.Text = "Stage: "..s.Value
  216. end
  217. end
  218. end)
  219.  
  220. ---------------------------------------------------------------
  221.  
  222. local UIS = game:GetService("UserInputService")
  223. UIS.InputBegan:Connect(function(input, gp)
  224. if input.KeyCode == Enum.KeyCode.R and not gp then
  225. local char = player.Character
  226. if char then
  227. local hum = char:FindFirstChildOfClass("Humanoid")
  228. if hum then hum.Health = 0 end
  229. end
  230. end
  231. end)
  232.  
  233. ---------------------------------------------------------------
  234.  
  235. local part = script.Parent
  236. part.Touched:Connect(function(hit)
  237. local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
  238. if plr then
  239. local stage = plr:FindFirstChild("leaderstats") and plr.leaderstats:FindFirstChild("Stage")
  240. if stage and stage.Value == #workspace.Checkpoints:GetChildren() then
  241. plr:Kick("🎉 You won the Obby! GG.")
  242. end
  243. end
  244. end)
  245.  
Advertisement
Add Comment
Please, Sign In to add comment