Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
8jxms 9
4 years ago

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)
0
Can you tell us what the model looks like in the Explorer Tab while testing? Geobloxia 251 — 4y
0
It looks the same 8jxms 9 — 4y

1 answer

Log in to vote
0
Answered by
karlo_tr10 1233 Moderation Voter
4 years ago
Edited 4 years ago

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

0
Thanks for the help! 8jxms 9 — 4y
Ad

Answer this question