#Data sometimes does not save even though there are no errors
34 messages · Page 1 of 1 (latest)
What does it look like
Its just saving one variable
Some have for loops some dont
So here’s a example
so its like thislua local DataStore = game:GetService('DataStoreService'):GetDataStore('Value') function PlayerAdding(player) local ls = Instance.new('Folder',player) ls.Name = 'leaderstats' local Cash = Instance.new('NumberValue',ls) Cash.Name = 'Cash' local Stage = Instance.new('NumberValue',ls) Stage.Name = 'Stage' local TpStage = Instance.new('NumberValue',ls) TpStage.Name = 'TeleportStage' local Saving = DataStore:GetAsync(player.UserId) for i,v in pairs(ls:GetChildren()) do v.Value = Saving[v.Name] end end function UpdateData(player) local Saving = {} local ls = player:FindFirstChild('leaderstats') for i,v in pairs(ls:GetChildren()) do Saving[v.Name] = v.Value end return Saving end function PlayerRemoving(player) local Update = UpdateData(player) DataStore:SetAsync(player.UserId,Update) end local Player = game.Players Player.PlayerAdded:Connect(function(player) PlayerAdding(player) end) Player.PlayerRemoving:Connect(function(player) PlayerRemoving(player) end)
So does that example look good to u
i did something similiar to this but sometimes lets say i get no cash and then when i rejoin a few mins later i get cash i had gotten before
ill try and review my code
does it say in the console that you're fetching from the datastore too often? sometimes it doesnt fulfill datarequest Get/SetAsync calls because they're called too quickly within other calls
nope its like u did, leaderstats. it just saves the leaderstats values every thirty seconds and when they leave
there are no errors and i made sure the auto save doesnt save too early when the player doesnt have any values in the leaderstats
For me it never goes away
well at some point it did so i changed it up a lil bit and now it doesnt
Also use a game bind to close to help it increases a chance to save if player didn’t leave on accident
yea i do
So what does the one u have look like
hold on
not to take away from the main point of the thread but what do you mean by a game bind? like the players.PlayerRemoving event?
the convert to string is to make the Tools in the inventory into stringvalues so i can save it into the datastore
Ye sometimes StringValue does that
?
Some times for me stringvalue doesn’t save for me also
oh
what i mean is like
im just saving the value of the strings and its working fine
but sometimes it doesnt load the entire data store
Try the example of what I did but write it so it can look good