Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't this loop work? [Solved]

As far as I'm concerned, this should work:

for _,v in pairs(workspace.Model:GetChildren() do
	if v.Name~="Part21" then
		v.Size=v.Size+Vector3.new(17,0,-17)
		v.CFrame=CFrame.new(v.CFrame.p,
		v.Parent['Part'..tostring(tonumber(string.sub(v.Name,5))+1)].CFrame.p)
	end
end
  • The Model is named Model, in the Workspace.
  • The Model consists of Parts labeled in order as "Part1" to "Part21"

As far as I'm concerned, this should work.

2 answers

✓ Accepted answer

You forgot the closing parenthesis for your pairs()

for _,v in pairs(workspace.Model:GetChildren()) do

On line 1, you need an extra ")" after the "()"

Correct:

for _,v in pairs(workspace.Model:GetChildren()) do

This discussion is preserved as it was. New answers, comments, and votes are closed.