So I have a noobie script that saves “cash” but I experienced it malfunction or atleast be too slow to work the way it should and by that I mean that I was gaining cash every 30 seconds and the last 2 times didn’t save.
When I was in live game the server was giving me “DataStore request was added to queue… Try sending fewer request keys” and also it sends out 5ish times each time I gain cash so that seems to be worrying.
here is the code I use:
local pfolder = game.Players
local DataStoreService = game:GetService("DataStoreService")
pfolder.PlayerAdded:Connect(function(plr)
print(plr.Name)
--
local playerKey = "Player_" .. plr.UserId
--
plr.ChildAdded:Connect(function(leaderstats)
wait(2)
--
local cash = plr.leaderstats.Cash
local cashs = DataStoreService:GetDataStore("Cash")
--
if cashs:GetAsync("Points"..plr.UserId)~= nil then
cash.Value = cashs:GetAsync("Points"..plr.UserId)
else
cash.Value = 0
end
cash.Changed:connect(function(val)
cashs:SetAsync("Points"..plr.UserId, val)
end)
end)
end)
Any help is appreciated