Here is the error i get Players.MasonX890.PlayerGui.ScreenGui.LocalScript:29: invalid argument #1 to ‘pairs’ (table expected, got Instance)
the Script i use:
function GetStats()
for _,v in next,Players:GetChildren() do
for _,c in next,v:WaitForChild("leaderstats"):GetChildren() do
if c:IsA("NumberValue") then
for _,vx in pairs(c) do
print(vx.Value)
end
end
end
end
end
As your error states, “Table expected, got Instance”.
In the code above, you make sure that c is a NumberValue. You then pass in said NumberValue to pairs, however, pairs can only be used with tables. Just as your error states.
local players = game:GetService("Players")
local function getStats()
for _, player in ipairs(players:GetPlayers()) do
local leaderstats = player:FindFirstChild"leaderstats"
if leaderstats then
for _, stat in ipairs(leaderstats:GetChildren()) do
if stat:IsA"ValueBase" then
if stat:IsA"NumberValue" or stat:IsA"IntValue" then
--Do code.
end
end
end
end
end
end