``local datastore = game:GetService("DataStoreService")
local data1 = datastore:GetDataStore("Data1")
game.Players.PlayerAdded:Connect(function(player)
local Data = Instance.new("Folder",player) Data.Name = "leaderstats" local cash = Instance.new("IntValue", Data) cash.Name = "Cash" cash.Value = data1:GetAsync(player.UserId) or 10 data1:GetAsync(player.UserId, cash.Value) cash.Changed:Connect(function() data1:GetAsync(player.UserId, cash.Value) end) game.Players.PlayerRemoving:Connect(function() data1:GetAsync(player.UserId, cash.Value) end)
while wait(30) do
data1:GetAsync(player.UserId, cash.Value)
end
end)
Help me no data saving script works for me.
First do not use :GetAsync() when updated or overwrite the values it make the server thinks that you use the Data Store more complicated. You need a limit. So for the limit of the :GetAsync() is 60+ number of players * 10 requests per minute. So if you have 10 players, so 60+10*10 = 700 request per minute so for this if you have more than 700 request per minute it maybe some bugs happen maybe if you have 100 coins makes 10 coins or if you have 20 coins makes 100 coins and so on. And tip, do not make server complicated in data store. So copy this script.
local datastore = game:GetService("DataStoreService") local data1 = datastore:GetDataStore("Data1") game.Players.PlayerAdded:Connect(function(player) local Data = Instance.new("Folder",player) Data.Name = "leaderstats" local cash = Instance.new("IntValue", Data) cash.Name = "Cash" cash.Value = data1:GetAsync(player.UserId) or 10 end) game.Players.PlayerRemoving:Connect(function() data1:GetAsync(player.UserId, cash.Value) end) -- For auto saving if you have a auto saved data while wait(60) do -- to make request per minute less and worked. data1:GetAsync(player.UserId, cash.Value) end
If not worked open the output. To open the output, click View on top the window, then click Output.