Hi, I want to make doors. I made a script that opens the door when a sign is clicked. The clickdetector and the script is inside the sign. They both are supposed to make another model inivisble. Can you tell me the issue with this code?
function onClicked() local children = game.Workspace.tardis1door:GetChildren() for c = 1, #children do if children[c].className == "" then children.Transparency= 1 children.CanCollide = false wait(5) children.Transparency= 0 children.CanCollide = true end end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Thanks
function onClicked() local children = game.Workspace.tardis1door:GetChildren() for c = 1, #children do if children[c].ClassName == "" then children[c].Transparency= 1 children[c].CanCollide = false wait(5) children[c].Transparency= 0 children[c].CanCollide = true end end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
You needed the [c] after children to select the specific child. It should work now.
Do : (Instead of a clicked script,More efficient way of doing it is .Touched)
script.Parent.Touched:connect(function(hit) lc = game.Workspace.tardis1door:GetChildren() lc.Transparency = 1 wait(5) lc.Transparency = 0 end)
Hope this helped.