I can't for the love of life figure out why but essentially, I've made a currency system that's designed to save your currency every time its value is changed, and it works great in studio, but not the client, I'm guessing something is wrong with how I'm saving it but I cannot figure it out. Studio Access to API Services is enabled and this is a script in ServerScriptService, can someone please help me with this?
local DataStore = game:GetService('DataStoreService'):GetDataStore("CurrencyStoreTest5")
game.Players.PlayerAdded:connect(function(player)
local currency = Instance.new("NumberValue")
currency.Parent = player
currency.Name = "CurrencyValue"
currency.Value = DataStore:GetAsync(player.userId)
player.CurrencyValue.Changed:connect(function()
print("Saving")
DataStore:SetAsync(player.userId, currency.Value)
print("Saved "..currency.Value.." coins")
end)
end)

5 comments
Wouldn't suggest firing a SetAsync every time the value changes. this will make you run out of possible Requests increadibly fast.
Thanks for the tip, Perhaps changing it every 3 times it's changed would help it out.
You can only set the same key once every 6 seconds max
Why are you not saving data when they leave the game?
Not very necessary with my old method of saving with saving every time it changes, but clearly it's a bad method and I will add the one where it saves when you leave