Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dss = game:GetService("DataStoreService")
- local datastore = dss:GetDataStore("Data")
- local startingJump = 0
- local function saveData(player)
- local data = {player.leaderstats.Jump.Value, player.leaderstats.Wins.Value}
- datastore:SetAsync(player.UserId, data)
- end
- local function loadData(player)
- local playerData = datastore:GetAsync(player.UserId) or {0, 0}
- local ls = Instance.new("Folder", player)
- ls.Name = "leaderstats"
- local jump = Instance.new("IntValue", ls)
- jump.Name = "Jump"
- jump.Value = playerData[1]
- local wins = Instance.new("IntValue", ls)
- wins.Value = playerData[2]
- wins.Name = "Wins"
- ls.Parent = player
- end
- game.Players.PlayerRemoving:Connect(saveData)
- game:BindToClose(function()
- for _, player in pairs(game.Players:GetPlayers()) do
- saveData(player)
- end
- end)
- game.Players.PlayerAdded:Connect(loadData)
- function handleWinPad(winpad)
- local onDebounce = {}
- local debounceTime = 5
- winpad.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player and not onDebounce[player] then
- onDebounce[player] = true
- player:LoadCharacter()
- player.leaderstats.Jump.Value = startingJump
- player.leaderstats.Wins.Value += tonumber(winpad.Name) or 1
- wait(debounceTime)
- onDebounce[player] = nil
- end
- end)
- end
- for _, winpad in pairs(workspace:WaitForChild("WinPads"):GetChildren()) do
- handleWinPad(winpad)
- end
- while true do
- wait(1)
- for _, player in pairs(game.Players:GetPlayers()) do
- local playerLS = player:WaitForChild("leaderstats")
- playerLS.Jump.Value += (1 + playerLS.Wins.Value)
- if player.Character and player.Character:FindFirstChild("Humanoid") then
- player.Character.Humanoid.JumpHeight = playerLS.Jump.Value
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement