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

Using SaveInstance/LoadInstance, has errors?

Asked by 9 years ago

Okay so this is a script in Workspace that is supposed to save all player's statistics every 5 minutes, and load them when the player joins. This does not work at all, and Output will not tell me the error. (I know i forgot the s at the end of leaderstat, I made it so that it is leaderstat so that they are not visible on the player list.)

function LoadStatistics(Player)
    Player:WaitForDataReady()
    ToLoad = Player.leaderstat:GetChildren()
    for i = 1,#ToLoad do
        ToLoad[i].Value = Player:LoadInstance(ToLoad[i].Name)
    end
    Message = Instance.new("Hint", Player.PlayerGui)
    Message.Text = "Successfully Loaded Statistics"
    wait(3)
    Message:Remove()
    script.Disabled = true --ye dis breaks sooo >_>
    script.Disabled = false
end
game.Players.PlayerAdded:connect(LoadStatistics)

while wait(300) do
    Search = game.Players:GetChildren()
    for i = 1,#Search do
        if Search[i]:findFirstChild("leaderstat") then
            ToSave = Search[i].leaderstat:GetChildren()
            for i = 1,#ToSave do
                Search[i]:SaveInstance(ToSave[i].Name, ToSave[i])
            end
        end
    end
    Message = Instance.new("Hint", game.Workspace)
    Message.Text = "Autosaved All Statistics"
    wait(3)
    Message:Remove()
end

1 answer

Log in to vote
0
Answered by 9 years ago

Solved it before anyone else could >.>

0
LOL koolkid8099 705 — 8y
Ad

Answer this question