You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to fix my datastore for currency, because it’s been reset back to 0 with no errors or anything in output at least 10 times within the last 2 weeks. -
What is the issue? Include screenshots / videos if possible!
Datastore for my currency keeps resetting but the avatar datastore is completely fine. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t found any solutions as most of them have errors and the others just aren’t similar enough.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local dss = game:GetService("DataStoreService")
local DSmoney = dss:GetDataStore("moneyBalance")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
money = Instance.new("IntValue")
money.Name = "Money"
money.Value = DSmoney:GetAsync(player.UserId)
money.Parent = leaderstats
if money.Value == nil then
money.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(player)
DSmoney:UpdateAsync(player.UserId, function(prev)
if money.Value == nil then
return money.Value
end
end)
end)
the avatar datastore is the same other than saving after you edit it, so I don’t know why the currency is having problems but the avatar editor isn’t