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

Can someone tell me why this traytable script isn't working(ClickDetector)?

I'm making a roblox airline and made it so that when you click the seat traytable it makes the bottom part visible. Instead of doing GetChildren() for the model I thought I would go the simple way and just manually set transparency for each one. But when I click it says union is not a valid member of model? Here is my explorer:

TrayTableDown
	Union
	Union1
	Union2
	Union3
	Union4
	Union5
	Part
	Part1

And this is the script I'm using:

local parts = game.Workspace.TrayTableDown

script.Parent.ClickDetector.MouseClick:Connect(function()
	parts.Union.Transparency = 0
	parts.Union1.Transparency = 0
	parts.Union2.Transparency = 0
	parts.Union3.Transparency = 0
	parts.Union4.Transparency = 0
	parts.Union5.Transparency = 0
	parts.Part1.Transparency = 0
	parts.Part.Transparency = 0
	script.Parent.Transparency = 1
end)

2 comments

0

Can you tell us what the model looks like in the Explorer Tab while testing?

0

It looks the same

1 answer

✓ Accepted answer

First of all, it may be due to that union not being anchored or other script deleting it. You can check ingame children of that model like this to make sure it's there.

local parts = game.Workspace.TrayTableDown

--- Use this to see what children it has ingame
for i,v in pairs(parts:GetChildren()) do
	print(v.Name)
end

Or you could just set transparency with loop (I read that you don't want but in case I will leave it here):

local parts = game.Workspace.TrayTableDown

for i,v in pairs(parts:GetChildren()) do
	if v:IsA("BasePart") then
		v.Transparency = 0
	end
end

1 comment

0

Thanks for the help!

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