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)
Have you tried putting into a LocalScript inside the object itself? If it's just a script in ScriptServerStorage, or Server storage then move it into the object itself.