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 change a property for all parts inside a model?

local canopy = script.Parent.Parent
local closed = canopy.canopyClosed
local open = canopy.canopyOpen

script.Parent.ClickDetector.MouseClick:connect(function()
	if canopy.state == false then --if its closed...
		open:GetChildren().Transparency = 0.7
		closed:GetChildren().Transparency = 1
		canopy.state = true
	elseif canopy.state == true then --if its open...
		open:GetChildren().Transparency = 1
		closed:GetChildren().Transparency = 0.7
		canopy.state = false
	end
end)

So for my jet project, I have a canopy setup. The canopy opens/closes by pressing a button. In short, the transparency of the open/closed canopies change. They are different models.

Each canopy model has 3 parts. Those parts are all "glass". I want to get the parts and change their transparency, as you can see with the above script. However, it's not working.

I know there's a specific way to do this, but I forgot. I appreciate the help!!

1 answer

✓ Accepted answer

This will go through every object in the model (not any lower descendants though) and set the transparency, change it to what you need

for _,c in pairs(model:GetChildren()) do --change model to wat you want
	if c:IsA("Part") then
		c.Transparency = 0 --change transparency to wat u want
	end
end

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