--Made By XlAscensionlX
--This is a really nooby Leaderscript I made, thanks to the wiki I know how now xD
--I may update this from time to time as I learn more and more scripting.
winsKey = "playerWins"
lossesKey = "playerLost"
game.Players.PlayerAdded:connect(function(player)
print ("A New Player ... " ..player.Name.. " ...Has Joined! Giving Leaderstats to!")
local leaderstats = Instance.new("Model",player)
leaderstats.Name = "leaderstats"
--Giving Wins Stats To.
local Wins = Instance.new("IntValue",leaderstats)
Wins.Name = "Wins"
Wins.Value = 0
local Loses = Instance.new("IntValue",leaderstats)
Loses.Name = "Losses"
Loses.Value = 0
--Load Data Saving
player:WaitForDataReady()
player.leaderstats.Value = player:LoadNumber(winsKey)
player.leaderstats.Value = player:LoadNumber(lossesKey)
end)
--Save The Players Wins/Losses For If The Ever Come Back.
game.Players.PlayerRemoving:connect(function(player)
if player:FindFirstChild("leaderstats") then
player:SaveNumber (winsKey, player.leaderstats.Wins)
player:SaveNumber (lossesKey, player.leaderstats.Loses)
end
end)
--This is needed for this script to work in "Play Solo"
for _, player in pairs(game.Players:GetPlayers()) do PlayerAdded(player) end
I have never had a problem with that. |