Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Using SaveInstance/LoadInstance, has errors?

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

This discussion is preserved as it was. New answers, comments, and votes are closed.