Invalid Argument?

I’m trying to make a car spawner for my friends game, It throws this error: Invalid argument #1 to pairs (table expected got instance), though I used :GetChildren() to get a table.

Code
local replicatedStorage = game:GetService("ReplicatedStorage")

local remotes = replicatedStorage:WaitForChild("remotes")

local spawnCar = remotes:WaitForChild("spawnCar")

local cars = replicatedStorage:WaitForChild("Cars")

for i,v in pairs(cars:GetChildren()) do
	local button = Instance.new("TextButton",script.Parent)
	button.Name = v.Name
	button.Text = v.Name
	button.TextSize = 18
	button.TextWrapped = true
	button.BorderSizePixel = 0
	button.BackgroundColor = Color3.fromRGB(33,33,33)
	
	button.MouseButton1Click:Connect(function()
		spawnCar:FireServer(v.Name)
	end)
end
1 Like

Are you sure this is line it errored? Try printing cars:GetChildren() just above the pairs to see if it’s actually a table and not an Instance.

1 Like

It returned with a table, so its not an instance.