How do i fix this error

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.

This is how i get c for _,c in next,v:WaitForChild(“leaderstats”):GetChildren() do
I think its a numberValue

I don’t understand why you are doing another for loop within it?

You have made one for loop (for_,c in ...), within it you have an if-statement to see whether it is a numberValue or not.

Why do you have yet another for-loop for each NumberValue?

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

May I ask why you have no parenthesis? Did you miss it or is this some common practice I am unaware of?

If the function has one single argument and this argument is either a literal string or a table constructor, then the parentheses are optional.

print"Hello world!"
print{}

It’s purely syntactic sugar.