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

Garage Does Not Work?

Asked by 9 years ago

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)
1
This looks correct. It is in a sever Script? Perci1 4988 — 9y
0
Is it in a server script or a local one? Local scripts only work if they're a child or a Player or Character. EzraNehemiah_TF2 3552 — 9y
0
No, this is in the object itself fight4money -2 — 9y
0
This is a normal script. fight4money -2 — 9y

1 answer

Log in to vote
0
Answered by
Carvyy 15
9 years ago

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.

0
Local Scripts cannot be in a part unless the part is a child of a Player or the Player's character. HopperBins are also acceptable. EzraNehemiah_TF2 3552 — 9y
0
So what should I do? fight4money -2 — 9y
Ad

Answer this question