Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --variables
- local checkpoints = workspace:WaitForChild("Checkpoints")
- local DataStoreService = game:GetService("DataStoreService")
- local plrStage = DataStoreService:GetDataStore("StageValue")
- local db = true
- --when plr joins
- game.Players.PlayerAdded:Connect(function(plr)
- local leaderstats = Instance.new("Folder")
- leaderstats.Name = "leaderstats"
- leaderstats.Parent = plr
- local v = Instance.new("IntValue")
- v.Value = plrStage:GetAsync(plr.UserId,v.Value) or 1
- v.Name = "Stage" --name of currency
- v.Parent = leaderstats
- print("Player Data Successfully Loaded!")
- v.Changed:Connect(function(value)
- plrStage:SetAsync(plr.UserId,value)
- print("Player Data Successfully Saved!")
- end)
- plr.CharacterAdded:Connect(function(char)
- local hum = char:WaitForChild("Humanoid")
- wait(0.1)
- wait(char:MoveTo(checkpoints[v.Value].Position))
- hum.Touched:Connect(function(hit)
- if hit.Parent == checkpoints and char.Humanoid.Health ~= 0 then
- if tonumber(hit.Name) == v.Value +1 then
- v.Value = v.Value +1
- end
- elseif hit.Parent == workspace.Damagers then
- char.Humanoid.Health = char.Humanoid.Health - 4
- db = false
- wait(.1)
- db = true
- elseif hit.Parent == workspace.Killers then
- char.Humanoid.Health = 0
- end
- end)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement