Trying to code game leaderstats so I don’t have to worry about it but this issue I think is hard for me and yes I am using the Aero DataStore System so that’s the reason there is an path named with Aero so is there a solution for this table error?
Code:
if not table.find(PlayerData.Inventory, Names) then table.insert(PlayerData.Inventory, Names) end
Error:
15:41:46.174 - ServerStorage.Aero.Services.GameData.Stats:271: missing argument #2
15:41:46.175 - Stack Begin
15:41:46.178 - Script 'ServerStorage.Aero.Services.GameData.Stats', Line 271 - function PlayerRemoved
15:41:46.179 - Stack End
local function PlayerRemoved(Player)
local Data = DataModule.ForPlayer(Player)
local success, PlayerData = Data:Get("PlayerData", PlayerDataSample):Await()
if (success) then
print("Data was Successfully Retrieved!")
else
warn("Failed to Retrieve Data!")
end
-- for Inventory Saving
for Names, Objects in pairs(Player.StarterGear:GetChildren()) do
if not table.find(PlayerData.Inventory, Names) then table.insert(PlayerData.Inventory, Names) end
for _, ChildrenObjects in pairs(Objects:GetChildren()) do
if ChildrenObjects:IsA("Folder") then
for Name, Values in pairs(ChildrenObjects:GetChildren()) do
--[[
String = ""
]]
local NormalTable = table.find(PlayerData.Inventory, Objects.Name)
table.insert(NormalTable, {Name = Values})
end
end
end
end
There is no such thing as “StarterGear” under the play. Its called the backpack.
If you put tools inside startergear in studio then it will be parented to every player under backpack.
So in the for loop try changing the Player.StarterGear to Player:WaitForChild(“Backpack”).
if this is the solution mark HawDevelopment’s comment above this one
Just for Clarity
StarterGear is not a Child of Player since it is not a Child of Player the “Names” variable will always return nil and since it is nil, that’s where you get the error so just change
The Solution was all along with@HawDevelopment’s Backpack but I also changed table.find which is very inefficient and ill leave a link here just ot prove and get no hate, this took me a long time just to figure it out lol