0

# [SOLVED] Why is my in-game currency Datastore not working?

Edited 8 months ago

I have been working on a game that uses in-game currency. I just made a datastore for the game to save the player's currency and work, but when I test it out (In-Studio and on Regular ROBLOX) it doesn't work. And yes, I do have Enable Studio Access to API Services turned on.

Here is my script:

local ds = game:GetService("DataStoreService"):GetDataStore("CoinsSave")

wait()
local key = "user_"..plr.UserId

local getSaved = ds:GetAsync(key)
if getSaved then
savevalue.Value = getSaved[1]
savevalue2.Value = getSaved[2]
else
local NumbersForSaving = {savevalue.Value, savevalue2.Value}

ds:GetAsync(key, NumbersForSaving)
end
end)

game.Players.PlayerRemoving:Connect(function(player)
end)


Any Help?

0
whats the error ur getting? ZeroToH3ro 82 — 8mo
0
I don't get any errors. It just does not save. JackyW9cky 27 — 8mo
0
It may be because when you set async you do "id_" player Userid, instead of "user_" player Userid, like how you have when the player joins Phase_Venom 55 — 8mo
0
Okay thanks. I'll try to replace the "id" to "user". JackyW9cky 27 — 8mo
0
I just replaced the "id" to "user" and it worked! Thank you so much! I have been trying to find out how to fix this problem for a very long time. JackyW9cky 27 — 8mo