Hello, nice to see you there! I am struggling to make and find a script that will save my leaderboard stats, as well has my inventory. The concept is that after each stage, it teleports you to a new game, with all your data. Is there any way i can do this? I tried many ways, but they were unsuccessful.
function onPlayerEntered(player)
wait()
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
if game.PlaceId == "224872882" or "224872666" then
ScoreLoad = true
end
game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeaving)
Thanks, Cake

1 comment
Indent pls XD