Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --If this doesn't work, I'm sorry. It should though.
- function saveScore(player, score)
- player:SaveNumber("Medals", score)
- end
- function loadScore(player, killCounter)
- local score = player:LoadNumber("Medals")
- if score ~= 0 then
- killCounter.Value = score
- else
- print("Nothing to load/score was 0")
- end
- end
- function onPlayerEntered(newPlayer)
- local stats = Instance.new("IntValue")
- stats.Name = "leaderstats"
- local clicks = Instance.new("IntValue")
- clicks.Name = "Medals"
- clicks.Value = 0
- clicks.Parent = stats
- stats.Parent = newPlayer
- wait(0.5)
- stats.Parent.PlayerGui.welcome.Opening.Visible = true
- stats.Parent.PlayerGui.pick.countries.Visible = true
- newPlayer:WaitForDataReady()
- loadScore(newPlayer, clicks)
- end
- function onPlayerRemoving(player)
- print("Attempting to save score for " .. player.Name)
- local stats = player:FindFirstChild("leaderstats")
- if (stats ~= nil) then
- local clicks = stats:FindFirstChild("Medals")
- if (clicks ~= nil) then
- saveScore(player, clicks.Value)
- end
- end
- end
- game.Players.PlayerAdded:connect(onPlayerEntered)
- game.Players.PlayerRemoving:connect(onPlayerRemoving)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement