I made and scripted a garage with 2 buttons: a green one to open the garage and a red one to close it. Problem is, it works in edit mode but not in Play mode. Help? (And yes there is a ClickDetector present)
There are 2 parts: gh and hg
The code for the green button:
function onClicked()
script.Parent.Parent.gh.CanCollide = false
script.Parent.Parent.gh.Transparency = 1
wait (0.3)
script.Parent.Parent.hg.CanCollide = false
script.Parent.Parent.hg.Transparency = 1
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
My code for the red button:
function onClicked()
script.Parent.Parent.gh.CanCollide = true
script.Parent.Parent.gh.Transparency = 0.6
wait (0.3)
script.Parent.Parent.hg.CanCollide = true
script.Parent.Parent.hg.Transparency = 0
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

4 comments
This looks correct. It is in a sever Script?
Is it in a server script or a local one? Local scripts only work if they're a child or a Player or Character.
No, this is in the object itself
This is a normal script.