Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Leaderboard Saving Wont Work? (Unanswered)

Asked by 10 years ago
SecondsKey = "SecondsPlayed"

game.Players.PlayerAdded:connect(function(player)
    player:WaitForDataReady()   

    leaderstats = Instance.new("IntValue")
    leaderstats.Parent = player
    leaderstats.Name = "leaderstats"

    SecondsPlayed = Instance.new("IntValue")
    SecondsPlayed.Parent = leaderstats
    SecondsPlayed.Name = "Seconds Played"
    SecondsPlayed.Value = 0

    while wait(1) do
        SecondsPlayed.Value = SecondsPlayed.Value +1
    end 
    SecondsPlayed.Value = player:LoadNumber(SecondsKey)
end)

game.Players.PlayerRemoving:connect(function(player)
    player:SaveNumber(SecondsKey, player.leadrstats.SecondsPlayed.Value)
end)

The saving doesn't work when I rejoin, I also shutdown all servers and rejoined. It still didn't work.

0
You misspelled leaderstats on line 22. And have the script load the number before the while loop. And put SecondsKey in quotations, since those are supposed to be string values to identify them. M39a9am3R 3210 — 10y
0
Still won't work... I posted the question again with the new code.. BosswalrusTheCoder 88 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago
repeat wait(1)

Try this instead of while wait(1)

Ad

Answer this question