Missing argument #1 to 'pairs' (table expected)

Basically I am making an Axe and Tree system, I want it so you can cut down the tree when you hit a proximity prompt, right now I am getting this error message, if you need the entire program I can provide it if needed! This script is a local script within the Axe Tool in Starterpack.

		for index, v in pairs() do
			if v:IsA("BasePart") then
				v.Anchored = false
				v.Transparency = 0.2
				task.wait(3)
				v.Transparency = 1
				v.CanCollide = false
			end
		end
		print("Health is 0")
		task.wait(30)
		Health = 5
		for _, v in pairs (game.workspace.Tree:GetDescendants())do
			if v.Name == 'Part' then
				v.Anchored = true
				v.Transparency = 0
				v.CanCollide = true
			end
		end

you forgot to add the table that you want to loop trough here

1 Like

I know this might seem really obvious but I have only just came back to programming so my apologies, but what is the table called?

1 Like

Well “table” can be anything in your context, in the pairs should be a table or something that returns a table (like the thing you used in your second for loop)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.