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.
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?
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.