Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Read the description of the model for details, it pretty much says to just put it in.
- function onPlayerEntered(player)
- wait()-- Change to wait for player longer.
- player:WaitForDataReady()
- repeat wait() until player:FindFirstChild("leaderstats")
- if player.DataReady then
- if player:findFirstChild("leaderstats") then
- local score = player.leaderstats:GetChildren()
- for i = 1,#score do
- local ScoreLoaded = player:LoadNumber(score[i].Name)
- wait()
- if ScoreLoaded ~= 0 then
- score[i].Value = ScoreLoaded
- end
- end
- end
- end
- end
- function onPlayerLeaving(player)
- if player:findFirstChild("leaderstats") then
- local score = player.leaderstats:GetChildren()
- for i = 1,#score do
- player:SaveNumber(score[i].Name,score[i].Value)
- end
- end
- end
- game.Players.PlayerAdded:connect(onPlayerEntered)
- game.Players.PlayerRemoving:connect(onPlayerLeaving)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement