sure I will share more of the scripts.
Itâs because more people means more requests.
here is some of the other scripts:
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local RunService = game:GetService("RunService")
local DataStore = DataStoreService:GetDataStore('youtubetutorialv:05')
--// Settings \\--
local StarterData = {
FirstCollider = false;
SecondCollider = false;
ThirdCollider = false;
FourthCollider = false;
FifthCollider = false;
SixthCollider = false;
SeventhCollider = false;
EighthCollider = false;
NeithCollider = false;
};
local playersavetable = {};
local AUTO_SAVE_INTERVAL = 180; -- time when the game auto saves
--// Functions \\--
local function loadStarterData(Player) -- loading the starter data
local Stats = Instance.new("Folder")
Stats.Name = 'DoorColliders'
Stats.Parent = Player
for statname, statvalue in pairs(StarterData) do
if type(statvalue) == "number" then
elseif type(statvalue) == 'boolean' then
local boolvalue = Instance.new("BoolValue")
boolvalue.Name = statname
boolvalue.Value = statvalue
boolvalue.Parent = Stats
elseif type(statvalue) == 'string' then
end
end
end
local function loadData(Player)-- Loading saved data
local Data
local s, e = pcall(function()
Data = DataStore:GetAsync('UserId'..Player.UserId)
end)
if s then
print('Getting '..Player.Name.."'s Collider for portal data was successful")
else
warn('something went wrong when loading'..Player.Name.."'s data")
end
if Data then
for statname, statvalue in pairs(Data) do
Player.DoorColliders[statname].Value = statvalue
end
print(Player.Name.."'s Collider for portal data has been loaded!")
else
print(Player.Name..' has no Collider for portal data! Generating new data')
end
end
local function saveData(Player)-- Saving data
if RunService:IsStudio() then return end
local Data = {}
for _, stat in pairs(Player.DoorColliders:GetChildren()) do
Data[stat.Name] = stat.Value
end
local s, e = pcall(function()
DataStore:SetAsync('UserId'..Player.UserId, Data)
end)
if s then
print(Player.Name.."'s data has been successfuly saved")
else
warn('Something went wrong while saving '..Player.Name.." 's data")
end
end
Players.PlayerAdded:Connect(function(player) -- loading the data when the player joins
playersavetable[player] = tick()
loadStarterData(player)
loadData(player)
end)
Players.PlayerRemoving:Connect(function(player) -- saving the data when a player quits the game
saveData(player)
end)
while true do
wait(1)
for _, player in pairs(Players:GetPlayers()) do
if tick() - playersavetable[player] >= AUTO_SAVE_INTERVAL then
saveData(player)
playersavetable[player] = tick()
end
end
end
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local RunService = game:GetService("RunService")
local DataStore = DataStoreService:GetDataStore('youtubetutorialv:07')
--// Settings \\--
local StarterData = {
['BackpackV'] = 30;
['CostUp'] = 50;
['NewST'] = 25;
};
local playersavetable = {};
local AUTO_SAVE_INTERVAL = 180; -- time when the game auto saves
--// Functions \\--
local function loadStarterData(Player) -- loading the starter data
local Stats = Instance.new("Folder")
Stats.Name = 'BackpackShop'
Stats.Parent = Player
for statname, statvalue in pairs(StarterData) do
if type(statvalue) == "number" then
local numbervalue = Instance.new("NumberValue")
numbervalue.Name = statname
numbervalue.Value = statvalue
numbervalue.Parent = Stats
elseif type(statvalue) == 'boolean' then
elseif type(statvalue) == 'string' then
end
end
end
local function loadData(Player)-- Loading saved data
local Data
local s, e = pcall(function()
Data = DataStore:GetAsync('UserId'..Player.UserId)
end)
if s then
print('Getting '..Player.Name.."'s PACK data was successful")
else
warn('something went wrong when loading'..Player.Name.."'s data")
end
if Data then
for statname, statvalue in pairs(Data) do
Player.BackpackShop[statname].Value = statvalue
end
print(Player.Name.."'s PACK data has been loaded!")
else
print(Player.Name..' has no PACK data! Generating new data')
end
end
local function saveData(Player)-- Saving data
if RunService:IsStudio() then return end
local Data = {}
for _, stat in pairs(Player.BackpackShop:GetChildren()) do
Data[stat.Name] = stat.Value
end
local s, e = pcall(function()
DataStore:SetAsync('UserId'..Player.UserId, Data)
end)
if s then
print(Player.Name.."'s data has been successfuly saved")
else
warn('Something went wrong while saving '..Player.Name.." 's data")
end
end
Players.PlayerAdded:Connect(function(player) -- loading the data when the player joins
playersavetable[player] = tick()
loadStarterData(player)
loadData(player)
end)
Players.PlayerRemoving:Connect(function(player) -- saving the data when a player quits the game
saveData(player)
end)
while true do
wait(1)
for _, player in pairs(Players:GetPlayers()) do
if tick() - playersavetable[player] >= AUTO_SAVE_INTERVAL then
saveData(player)
playersavetable[player] = tick()
end
end
end
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local RunService = game:GetService("RunService")
local DataStore = DataStoreService:GetDataStore('youtubetutorialv:04')
--// Settings \\--
local StarterData = {
['Awesome Ninja'] = false;
['Experianced Ninja'] = false;
['INF'] = false;
['Intermediate Fighter'] = false;
['Katana'] = false;
['Katana Pro'] = false;
['Katana Supreme'] = false;
['Kunai'] = false;
['Kunai Master'] = false;
['Kunai Pro'] = false;
['Kunai Supreme'] = false;
['Mega Knight'] = false;
['Melee Pro'] = false;
['Melee Super'] = false;
['Nerd Fighter'] = false;
['Ninja'] = false;
['Ninja Recruit'] = false;
['Ninja sensei'] = false;
['Noob Fighter'] = false;
['Sensei Master'] = false;
['Sensei Supreme'] = false;
['Starter Fighter'] = false;
['Street Fighter'] = false;
['Strong Fighter'] = false;
['Sumo Fighter'] = false;
['Super Human Fighter'] = false;
['Supreme Knight'] = false;
['shuriken'] = false;
['shuriken Master'] = false;
['shuriken Supreme'] = false;
['Kunai Pro'] = false;
['Kunai Supreme'] = false;
['Mega Knight'] = false;
['Melee Pro'] = false;
['Melee Super'] = false;
['Nerd Fighter'] = false;
['Ninja'] = false;
['Ninja Recruit'] = false;
['Ninja sensei'] = false;
['Noob Fighter'] = false;
['Sensei Master'] = false;
['Sensei Supreme'] = false;
['Starter Fighter'] = false;
['Street Fighter'] = false;
['Strong Fighter'] = false;
['Sumo Fighter'] = false;
};
local playersavetable = {};
local AUTO_SAVE_INTERVAL = 180; -- time when the game auto saves
--// Functions \\--
local function loadStarterData(Player) -- loading the starter data
local Stats = Instance.new("Folder")
Stats.Name = 'Packs'
Stats.Parent = Player
for statname, statvalue in pairs(StarterData) do
if type(statvalue) == "number" then
elseif type(statvalue) == 'boolean' then
local boolvalue = Instance.new("BoolValue")
boolvalue.Name = statname
boolvalue.Value = statvalue
boolvalue.Parent = Stats
elseif type(statvalue) == 'string' then
end
end
end
local function loadData(Player)-- Loading saved data
local Data
local s, e = pcall(function()
Data = DataStore:GetAsync('UserId'..Player.UserId)
end)
if s then
print('Getting '..Player.Name.."'s pack bool data was successful")
else
warn('something went wrong when loading'..Player.Name.."'s data")
end
if Data then
for statname, statvalue in pairs(Data) do
Player.Packs[statname].Value = statvalue
end
print(Player.Name.."'s pack bool data has been loaded!")
else
print(Player.Name..' has no pack bool data! Generating new data')
end
end
local function saveData(Player)-- Saving data
if RunService:IsStudio() then return end
local Data = {}
for _, stat in pairs(Player.Packs:GetChildren()) do
Data[stat.Name] = stat.Value
end
local s, e = pcall(function()
DataStore:SetAsync('UserId'..Player.UserId, Data)
end)
if s then
print(Player.Name.."'s data has been successfuly saved")
else
warn('Something went wrong while saving '..Player.Name.." 's data")
end
end
Players.PlayerAdded:Connect(function(player) -- loading the data when the player joins
playersavetable[player] = tick()
loadStarterData(player)
loadData(player)
end)
Players.PlayerRemoving:Connect(function(player) -- saving the data when a player quits the game
saveData(player)
end)
while true do
wait(1)
for _, player in pairs(Players:GetPlayers()) do
if tick() - playersavetable[player] >= AUTO_SAVE_INTERVAL then
saveData(player)
playersavetable[player] = tick()
end
end
end
I think its because all of the scripts are auto saving at the same time, try changing them for each
Its not really an error so you can ignore cause I had that in my games and it did nothing
you can also increase the wait number or limit the players
Try checking your budget using the function I sent you, and if your budgets low, adjust accordingly.
I will try some of you guysâs ideas. My server Limit is 10 players per server
I have had this same problem, when all of them save at the same time, its too much and i got that error.
Ok then just ignore the error(its not an error it just info about data being saved on a user)
Thatâs a terrible idea! Data loss can occur if he donât fix it and he also said that it breaks his game.
(post deleted by author)
Itâs because youâre autosaving by actually saving to the datastore, which is something you donât need. You really only need to save data whenever a player leaves, or if they do something important (ex. make a purchase). You cant make a request to the same key in under 6 seconds, so what probably happens is that it autosaved for someone and then they left the game right after within the 6 seconds. This scenario could also happen in a real game, meaning that the player who leaves within 6 seconds of an autosave would lose all of their data for that session because it would throw an error.
To do autosaving you need to do something like caching the data in a table from a ModuleScript. Thatâs what I do and most people I see do, at least. Some form of caching needs to be involved (this is part of the reason why DataStore2 was created, so you can use that even though I donât use it). This solution is way better than using SaveAsync because you avoid limits, but you still have security because it would work in the same way as a normal autosave.
How it would work is something like this. This is what I do:
-
Player leaves the game
-
SaveAsync fails on their data when they left, but then you need to do some SaveAsync retries (usually it doesnât even go past here, works usually after some retries)
-
Itâs a worst case scenario, so then that fails as well. So, THEN you can retrieve the data that had been cached for that player by the autosave, and try saving that, and if that fails, do some retries again.
Thereâs a 99% chance of you not ever having to go past step 1 (data failing to save) if you do this right. If something goes wrong, you have so much to back it up with.
You should also change the name of the DataStore sometimes when you run into errors, cause sometimes for me that magically fixes things (but this will create a new one, so mind the limits of how many you can make per game
Best thing to do is to just save when their leaving or buying something.
Yeah exactly, thatâs what I said
alr i just waked up, I will try some of you guyâs ideas.
I have a question, I tested my game with half a server full and everything was fine. But when a lot of players joined at the same time it causes that warning/error and breaks my game apart.
I have other data stores that donât use tables and save separately maybe its that causing the data to break?
I am just wondering that if example there is 30 separate data store saving, maybe thatâs why my game breaks and is maybe not related to the code above?
You need to combine them into one datastore, or else youâre going to hit the limit.