If then loop requiring "do" for some reason

so i’m having an issue with a if condition then action end loop

Essentially this:

	for i, v in pairs(body)
		if v:IsA('BasePart') then
			v.BrickColor = setto
		end
	end

returns this error:

Workspace.Gen.Generator.Generate Capsule:19: Expected 'do' when parsing for loop, got 'if'

and points to the if next to if v:IsA

help

1 Like

This is Lua scripting. Seems most every language has a different versions of loops.

for _, v in pairs(body) do
	if v:IsA('BasePart') then
		v.BrickColor = setto
	end
end
1 Like

i dont think it matters if it’s i,v or _,v but by comparing the code, it was missing a “do” after the ...pairs(body)

1 Like

The _ is used when it really don’t matter … (it’s not going to be used in the loop for anything)
It’s also personal preference.

1 Like

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