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

Need help getting this script to affect all parts in a model?

Basically i need this script :

function myfunction()

script.Parent.Parent.Undercarriage.Transparency = 1 script.Parent.Parent.Undercarriage.CanCollide = false

end

script.Parent.ClickDetector.MouseClick:connect(myfunction)

To affect all the parts in the model called undercarriage, not just one which it is at the moment. Theres roughly 100 parts in this model called undercarriage so naming them all will be highly impractical and time consuming.

I'm a complete noob to scripting, don't judge me too harshly :D

1 answer

Sorry I can't explain any better.

function myfunction()  -- Function
	for i,v in pairs(script.Parent.Parent:GetChildren()) do -- Gather all the parts
		if v.Name == "Undercarriage" then -- If it's named a specific name
			v.Transparency = 1 -- Change the transparency
			v.CanCollide = false -- Make it CanCollide false
		end -- End the function
	end -- End the gathering
end -- End the if
-- Or I got the ending's in the wrong order e.e
script.Parent.ClickDetector.MouseClick:connect(myfunction) -- On click

2 comments

0

Thanks, worked perfectly :D

0

No problem.

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