Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local Checkpoints = workspace:WaitForChild("Checkpoints"):GetChildren()
- local spawnPart = workspace:WaitForChild("SpawnLocation")
- local stageCount = #Checkpoints
- table.sort(Checkpoints, function(a,b)
- return tonumber(a.Name) < tonumber(b.Name)
- end)
- local function getCheckpoint(stage)
- for _, checkpoint in ipairs(Checkpoints) do
- if tonumber(checkpoint.Name) == stage then
- return checkpoint
- end
- end
- return spawnPart
- end
- local DataStoreService = game:GetService("DataStoreService")
- local stageData = DataStoreService:GetDataStore("StageData")
- Players.PlayerAdded:Connect(function(player)
- local leaderstats = Instance.new("Folder", player)
- leaderstats.Name = "leaderstats"
- local stage = Instance.new("IntValue", leaderstats)
- stage.Name = "Stage"
- local savedStage = stageData:GetAsync(player.UserId)
- if savedStage then
- stage.Value = savedStage
- else
- stage.Value = 1
- end
- player.CharacterAdded:Connect(function(char)
- wait(0.5)
- local checkpoint = getCheckpoint(stage.Value)
- if checkpoint then
- char:MoveTo(checkpoint.Position + Vector3.new(0, 5, 0))
- end
- local root = char:WaitForChild("HumanoidRootPart")
- while char.Parent do
- wait(0.5)
- if root.Position.Y < -20 then
- char:MoveTo(getCheckpoint(stage.Value).Position + Vector3.new(0, 5, 0))
- end
- end
- end)
- end)
- Players.PlayerRemoving:Connect(function(player)
- local stage = player:FindFirstChild("leaderstats"):FindFirstChild("Stage")
- if stage then
- stageData:SetAsync(player.UserId, stage.Value)
- end
- end)
- -----------------------------------------------------
- local checkpointPart = script.Parent
- checkpointPart.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- local stage = tonumber(checkpointPart.Name)
- local current = player:FindFirstChild("leaderstats"):FindFirstChild("Stage")
- if stage and current and stage > current.Value then
- current.Value = stage
- end
- end
- end)
- -----------------------------------------------------
- local player = game.Players.LocalPlayer
- local gui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
- local stageText = Instance.new("TextLabel", gui)
- gui.Name = "StageUI"
- stageText.Size = UDim2.new(0, 200, 0, 50)
- stageText.Position = UDim2.new(0, 20, 0, 20)
- stageText.BackgroundTransparency = 0.3
- stageText.BackgroundColor3 = Color3.fromRGB(0,0,0)
- stageText.TextColor3 = Color3.new(1,1,1)
- stageText.TextScaled = true
- stageText.Font = Enum.Font.GothamBold
- local function update()
- while true do
- local stat = player:WaitForChild("leaderstats"):WaitForChild("Stage")
- stageText.Text = "Stage: "..stat.Value.." / "..stageCount
- wait(0.5)
- end
- end
- spawn(update)
- -----------------------------------------------------
- local finishPart = script.Parent
- finishPart.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- local stat = player:FindFirstChild("leaderstats"):FindFirstChild("Stage")
- if stat and stat.Value == stageCount then
- player:Kick("🎉 Congratulations! You finished the obby.")
- end
- end
- end)
- local Players = game:GetService("Players")
- local DSS = game:GetService("DataStoreService")
- local stageData = DSS:GetDataStore("StageSave")
- local Checkpoints = workspace:WaitForChild("Checkpoints"):GetChildren()
- table.sort(Checkpoints, function(a, b) return tonumber(a.Name) < tonumber(b.Name) end)
- local function getCheckpoint(stage)
- for _, c in ipairs(Checkpoints) do
- if tonumber(c.Name) == stage then return c end
- end
- return workspace:WaitForChild("SpawnLocation")
- end
- Players.PlayerAdded:Connect(function(player)
- local stats = Instance.new("Folder", player)
- stats.Name = "leaderstats"
- local stage = Instance.new("IntValue", stats)
- stage.Name = "Stage"
- stage.Value = stageData:GetAsync(player.UserId) or 1
- player.CharacterAdded:Connect(function(char)
- task.wait(0.5)
- local pos = getCheckpoint(stage.Value).Position + Vector3.new(0,3,0)
- char:MoveTo(pos)
- local hrp = char:WaitForChild("HumanoidRootPart")
- while char.Parent do
- task.wait(0.5)
- if hrp.Position.Y < -20 then
- char:MoveTo(getCheckpoint(stage.Value).Position + Vector3.new(0,3,0))
- end
- end
- end)
- end)
- Players.PlayerRemoving:Connect(function(player)
- local stage = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Stage")
- if stage then
- stageData:SetAsync(player.UserId, stage.Value)
- end
- end)
- ---------------------------------------------------------------
- local checkpoint = script.Parent
- checkpoint.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- local s = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Stage")
- if s and tonumber(checkpoint.Name) > s.Value then
- s.Value = tonumber(checkpoint.Name)
- local sound = checkpoint:FindFirstChild("Sound")
- if sound then sound:Play() end
- end
- end
- end)
- ---------------------------------------------------------------
- local player = game.Players.LocalPlayer
- local gui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
- gui.Name = "ObbyUI"
- local stageLabel = Instance.new("TextLabel", gui)
- stageLabel.Size = UDim2.new(0, 200, 0, 40)
- stageLabel.Position = UDim2.new(0, 20, 0, 20)
- stageLabel.BackgroundColor3 = Color3.new(0,0,0)
- stageLabel.TextColor3 = Color3.new(1,1,1)
- stageLabel.TextScaled = true
- stageLabel.Text = "Stage: ?"
- stageLabel.Font = Enum.Font.GothamBold
- local timerLabel = Instance.new("TextLabel", gui)
- timerLabel.Size = UDim2.new(0, 200, 0, 40)
- timerLabel.Position = UDim2.new(0, 20, 0, 70)
- timerLabel.BackgroundColor3 = Color3.new(0,0,0)
- timerLabel.TextColor3 = Color3.new(1,1,1)
- timerLabel.TextScaled = true
- timerLabel.Text = "Time: 0s"
- timerLabel.Font = Enum.Font.GothamBold
- local time = 0
- spawn(function()
- while true do
- wait(1)
- time += 1
- timerLabel.Text = "Time: "..time.."s"
- end
- end)
- spawn(function()
- while true do
- wait(0.5)
- local s = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Stage")
- if s then
- stageLabel.Text = "Stage: "..s.Value
- end
- end
- end)
- ---------------------------------------------------------------
- local UIS = game:GetService("UserInputService")
- UIS.InputBegan:Connect(function(input, gp)
- if input.KeyCode == Enum.KeyCode.R and not gp then
- local char = player.Character
- if char then
- local hum = char:FindFirstChildOfClass("Humanoid")
- if hum then hum.Health = 0 end
- end
- end
- end)
- ---------------------------------------------------------------
- local part = script.Parent
- part.Touched:Connect(function(hit)
- local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
- if plr then
- local stage = plr:FindFirstChild("leaderstats") and plr.leaderstats:FindFirstChild("Stage")
- if stage and stage.Value == #workspace.Checkpoints:GetChildren() then
- plr:Kick("🎉 You won the Obby! GG.")
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment