I've got this much from the wiki, I need help with the last part.
scoreKey = "PlayerScore"
game.Players.PlayerAdded:connect(function(player)
if player:WaitForDataReady() then
local leaderstats = Instance.new("IntValue", player)
leaderstats.Name = "leaderstats"
local cash = Instance.new("IntValue", leaderstats)
cash.Name = "Cash"
cash.Value = player:LoadNumber(scoreKey)
local xp = Instance.new("IntValue", leaderstats)
xp.Name = "XP"
xp.Value = player:LoadNumber(scoreKey)
end
end)
game.Players.PlayerRemoving:connect(function(player) -- How do I change this so when you click a TextButton it will save your data?
if player:findFirstChild("leaderstats") then
player:SaveNumber(scoreKey, player.leaderstats.Score.Value)
end
end)
