I'm trying to make it so when I click the "OPEN" text button on the surface gui, the door will turn transparent, turn CanCollide off, and allow me to walk through it. I've done scripts like this before, and have been successful, this just doesn't work. Please help.
Door=game.Workspace.Door function open() print("Opening Door") Door.Transparency=1 Door.CanCollide=false wait(10) Door.Transparency=0 Door.CanCollide=true end script.Parent.MouseButton1Down:connect(open)
Door=game.Workspace.Door function opendoor() print("Opening Door") Door.Transparency=1 Door.CanCollide=false wait(5) Door.Transparency=0 Door.CanCollide=true end script.Parent.MouseButton1Click:connect(opendoor)
This works.
Firstly you need to insert a ClickDetector either in the script or in the brick. Secondly your connection line is wrong it should be
This: Door.ClickDetector.MouseClick:connect(open) Here is the finished script. Door=script.Parent a = Instance.new("ClickDetector",Door)--added function open() print("Opening Door") Door.Transparency=1 Door.CanCollide=false wait(10) Door.Transparency=0 Door.CanCollide=true end Door.ClickDetector.MouseClick:connect(open) -- fixed
If you wanted to do this with a Gui is is pretty simple here is how 1.Put a screenGui inside of StarterGui 2.Add a text button inside of the ScreenGui 3.Add a localscript inside of the textbutton 4.add this code
Door=game.Workspace.door button = script.Parent function open() print("Opening Door") Door.Transparency=1 Door.CanCollide=false wait(10) Door.Transparency=0 Door.CanCollide=true end button.MouseButton1Down:connect(open)