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

TextButtons and Surfacegui?

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

✓ Accepted answer
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.

1 comment

0

Thanks!

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)

1 comment

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

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