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

How do I make this script work for each part in a model in one script?

I need this where I can just place it in the model and it'll work for each part ( to prevent lag ).

function fall()
	script.Parent:BreakJoints()
end

script.Parent.Touched:connect(fall)

Thank you in advance for any help you may provide.

1 answer

✓ Accepted answer

GetChildren

Simply connect the event for every child in the model:

for k,v in next, script.Parent:GetChildren() do
  v.Touched:connect(function()
    v:BreakJoints()
  end)
end

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