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") game.Players.PlayerAdded:Connect(function(plr) wait() local key = "user_"..plr.UserId local savevalue = plr.leaderstats.Coins local savevalue2 = plr.leaderstats.Level 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) ds:SetAsync("id_"..player.UserId, {player.leaderstats.Coins.Value, player.leaderstats.Level.Value}) end)
Any Help?