I think there might be somethings that are unclear, when a Player leaves the game is when a PlayerRemoving event fires, but when the player is completley out of the game, the player object is nil meaning you can’t run something on a nil object. So the loop will stop. All I’m saying if the player has left the game player object is nil, player scripts will stop running. I could definetly be wrong but I’ve asked a question like this in the past, maybe things could’ve changed, who knows? Enjoy your day
I know it should work. But:
13:23:08.526 Player Data successfully loaded! - Server - ClickDataStore:18
13:23:08.526 Last saved Click data: 0 - Server - ClickDataStore:19
13:23:21.105 Most recent Click data save: 0 - Server - ClickDataStore:27
13:23:21.105 There was an error when saving data - Server - ClickDataStore:36
13:23:21.104 Disconnect from ::ffff:127.0.0.1|64348 - Studio
I don’t know what is wrong as I literally copied and pasted the final version you made.
These are the only things in the game:
publish ur game and migrate it to the latest update then test it, the script should work maybe because ur in studio or sumn?
Ok thanks. I will try this, hopefully it works.
Could it possibly be because the ledearsats script is resetting the stat to 0?
game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = player
local Clicks = Instance.new("IntValue")
Clicks.Name = "Clicks"
Clicks.Value = 0
Clicks.Parent = stats
local Gems = Instance.new("IntValue")
Gems.Name = "Gems"
Gems.Value = 0
Gems.Parent = stats
local Rebirths = Instance.new("IntValue")
Rebirths.Name = "Rebirths"
Rebirths.Value = 0
Rebirths.Parent = stats
local Eggs = Instance.new("IntValue")
Eggs.Name = "Eggs"
Eggs.Value = 0
Eggs.Parent = stats
end)
Creating stats on the player doesn’t have anything to do with data stores, you use them to load their stats later, also you don’t have to do .Value = 0, but it shouldn’t be causing problems, since the actual data would be loaded afterwards,
Is that your entire script? That script won’t save anything; Or are you just showing your stats?
Can we see it entirely?
Also that loop to save data is usually not that useful from my experience, player data would usually save better only on leaving;
everythings been fixed if u read the previous soloutions but thats not why im replying
setting value = 0 is important because if you leave it empty it will be nil and nil+1 = error
so its perfectly fine to set it to 0 and anything can be to do with data stores they’re just something to hold values.
No lol, the default value for IntValues are 0, just like string values default value is “” and not nil;
output:
output:
That’s a variable, not a IntValue. Variables can be anything, and so if not defined will be nil. IntValue can only carry numbers.
yes however thats not what you said, you said “Stats” the variable we were using so i can only asume that you were talking about the variable
If it’s stats then it’s obviously leaderstats. Which hold IntValues as objects
ah yes… sorry about all the misunderstanding i thought u were talking about a variable, blonde moment anyway always fun to disagree on things!
Yes as I said above putting a loop or a autosave will make everyones data not save within like 20 minutes or something because your overloading datastores