Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Garage Does Not Work?

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

1

This looks correct. It is in a sever Script?

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.

0

No, this is in the object itself

0

This is a normal script.

1 answer

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.

2 comments

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.

0

So what should I do?

This discussion is preserved as it was. New answers, comments, and votes are closed.