Can someone help fix this script so it saves the two values. (Credits and Wins)
right now it only saves one.
WinsValue = 'PlayerScore'
CreditsValue = 'PlayerScore'
game.Players.PlayerAdded:connect(function(Player)
local Leaderstats = Instance.new('Folder')
Leaderstats.Name = 'leaderstats'
Leaderstats.Parent = Player
local Wins = Instance.new('IntValue')
Wins.Name = 'Wins'
Wins.Parent = Leaderstats
Wins.Value = 0
local Credits = Instance.new('IntValue')
Credits.Name = 'Credits'
Credits.Parent = Player
Credits.Value = 100
if Player:WaitForDataReady() then
Player.leaderstats.Wins.Value = Player:LoadNumber(WinsValue)
Player.Credits.Value = Player:LoadNumber(CreditsValue)
end
end)
game.Players.PlayerRemoving:connect(function(Player)
if Player:FindFirstChild('leaderstats') then
Player:SaveNumber(WinsValue, Player.leaderstats.Wins.Value)
Player:SaveNumber(CreditsValue, Player.Credits.Value)
end
end)
|