local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("CoinsSaveSystem") game.Players.PlayerAdded:connect(function(plr) local ls = Instance.new("Folder", plr) ls.Name = "leaderstats" local st = Instance.new("StringValue") st.Name = "Coins" st.Parent = ls st.Value = 0 st.Value = ds1:GetAsync(plr.UserId) or 0 ds1:SetAsync(plr.UserId, st.Value) st.Changed:connect(function() ds1:SetAsync(plr.UserId, st.Value) end) end)
11:52:19.993 - DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 38381653 (x21)
after x30 requests are sent this just drops the saves, how do i make this infinite? if its even possible.
How do i save when a player leaves?
local DataStoreService = game:GetService("DataStoreService") local saveDataStore = DataStoreService:GetDataStore("ChangeThis") -- When the player join load the saved stats game.Players.PlayerAdded:connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr -- example with 2 data (cash & kill) you can add more if you want local cash = Instance.new("IntValue") cash.Name = "Cash" cash.Value = 10 cash.Parent = leaderstats local kill = Instance.new("IntValue") kill.Name = "Kill" kill.Value = 0 kill.Parent = leaderstats -- Get the saved data local data = saveDataStore:GetAsync(plr.UserId) if data then for i, v in pairs(leaderstats:GetChildren()) do v.Value = data[v.Name] end end end) -- When the player leave save the data game.Players.PlayerRemoving:connect(function(plr) local leaderstats = plr:FindFirstChild("leaderstats") if leaderstats then local saveData = {} for i, v in pairs(leaderstats:GetChildren()) do saveData[v.Name] = v.Value end saveDataStore:SetAsync(plr.UserId, saveData) end end)