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

How to ignore clickdetector in script, it causes an error when trying to make model transparent?

I'm try to make a model become transparent and not transparent in a script but my clickdetector is in one of the parts inside the model, causing the error "Clickdetector is not a vaild member" since you can't make a clickdetector transparent. I can't figure out how to make it so it ignores the clickdetector though.

local SP = script.parent
local D = SP.Demat
local D2 = D.Demat
local AS = SP.Animationsnap
local CD = D.Demat.ClickDetector

CD.MouseClick:Connect(function()
	for _, c in ipairs(AS:GetChildren()) do
			c.Transparency = 0
			for _, DM in ipairs(D2:GetChildren()) do
			DM.Transparency = 1
			wait(0.5)
			for _, c in ipairs(AS:GetChildren()) do
				c.Transparency = 1
				for _, DM in ipairs(D2:GetChildren()) do
					DM.Transparency = 0
				end
		end
		end
		end
	end)

2 answers

✓ Accepted answer

If you only wanted to get parts you can do this:

for _,v in pairs(model:GetChildren()) do
	if v:IsA("BasePart") then
		-- do code
	end
end

If you also want to include the children of children in the loop you can use :GetDescendants().

2 comments

0

I tried that but it said the same thing.

0

It goes in between lines 08 and 09.

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