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

TextButtons and Surfacegui?

Asked by 9 years ago

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)

2 answers

Log in to vote
0
Answered by 9 years ago
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.

0
Thanks! LastTimeLord12 5 — 9y
Ad
Log in to vote
0
Answered by
Damo999 182
9 years ago

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)
0
It still doesn't work, I'm not sure why. Also, clickdetectors don't join with textbuttons. I also should mention this is a surface gui LastTimeLord12 5 — 9y

Answer this question