I have three parts to a door. One is a union, and the other two are regular parts. I put this script inside the union in hopes of making the union and the other two parts disappear when the union was clicked... but, it doesn't work. I don't know what I did wrong.
h = script.Parent.Parent.Handle k = script.Parent.Parent.Knob u = script.Parent function onclicked() if h.Transparency == 0 and k.Transparency == 0 and u.Transparency == 0 and h.CanCollide == true and k.CanCollide == true and u.CanCollide == true then h.Transparency = 1 k.Transparency = 1 u.Transparency = 1 h.CanCollide = false k.CanCollide = false u.CanCollide = false else h.Transparency = 0 k.Transparency = 0 u.Transparency = 0 h.CanCollide = true k.CanCollide = true u.CanCollide = true end end script.Parent.ClickDetector.MouseClick:connect(onclicked)
If anyone could tell me what I did incorrectly, that would be awesome.
There is a much simpler way to do this:
h = script.Parent.Parent.Handle k = script.Parent.Parent.Knob u = script.Parent local open = true function onclicked() if open then h.Transparency = 1 k.Transparency = 1 u.Transparency = 1 h.CanCollide = false k.CanCollide = false u.CanCollide = false open = true else h.Transparency = 0 k.Transparency = 0 u.Transparency = 0 h.CanCollide = true k.CanCollide = true u.CanCollide = true open = false end end script.Parent.ClickDetector.MouseClick:connect(onclicked)