Bug? IntValue not reflecting correct Value

So I have a datstore script in which it saves the count of an object along with the name of an object. While the datastore script works as intended (loading the correct number), the intvalue that the datastore saves the value of is always loading at 0.

image
image

I asked my friend to go on and repeat the same steps (changing the number) which is saved then loading back in, they faced no issue and the script works as intended. Is this a scripting bug?

Changing the intvalue locally or on the server?

1 Like

Server-wise. I think it was a bug because after leaving and joining back studio, it fixed itself.

1 Like

Its because in studio, when you test and leave the server actually shuts down. The data sometimes won’t save. You should have a game:BindToClose() function and loop through players to actually save their data.

game:BindToClose(function()
	for i,player in pairs(game.Players:GetChildren())do
		SaveData(player)
	end
end)

And ofcourse, this is additional, you should always have your PlayerRemoving function with this, game:BindToClose() is for servershutdowns, server crashes and all that.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.