Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dss = game:GetService("DataStoreService")
- local obbyDS = dss:GetDataStore("ObbyData")
- local checkpoints = workspace.Checkpoints
- game.Players.PlayerAdded:Connect(function(plr)
- local obbyData = obbyDS:GetAsync(plr.UserId .. "-obbyStageProgress")
- local ls = Instance.new("Folder")
- ls.Name = "leaderstats"
- ls.Parent = plr
- local stage = Instance.new("StringValue")
- stage.Name = "Stage"
- stage.Value = obbyData or 1
- stage.Parent = ls
- local char = plr.Character or plr.CharacterAdded:Wait()
- char:waitForChild("HumanoidRootPart"):GetPropertyChangedSignal("CFrame")
- char:WaitForChild("HumanoidRootPart").CFrame = checkpoints[stage.Value].CFrame
- char.Humanoid.Touched:Connect(function(touch)
- if touch.Parent == checkpoints then
- if (tonumber(touch.Name) and tonumber(touch.Name) > tonumber(stage.Value)) or touch.Name == "End" then
- stage.Value = touch.Name
- pcall(function()
- obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
- end)
- end
- end
- end)
- plr.CharacterAdded:Connect(function(char)
- local hrp = char:WaitForChild("HumanoidRootPart")
- local humanoid = char:WaitForChild("Humanoid")
- hrp:GetPropertyChangedSignal("CFrame"):Wait()
- hrp.CFrame = checkpoints[stage.Value].CFrame
- humanoid.Touched:Connect(function(touch)
- if touch.Parent == checkpoints then
- if (tonumber(touch.Name) and tonumber(touch.Name) > tonumber(stage.Value)) or touch.Name == "End" then
- stage.Value = touch.Name
- pcall(function()
- obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
- end)
- end
- end
- end)
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- pcall(function()
- obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement