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

Button Door help?

How do you make a door open and close using green and red parts as its buttons?

4 answers

You would insert a clickdetector to the object that your going to click on.

Then you would make a onClicked Script code line.

It would look like this:

function onClicked()
      if player onClicked then
door.Transparency = 0
door.CanCollide = true

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Learn the event MouseClick and about the Object ClickDetector

2 comments

1

I tried to use it but it didn't work, I'm new to scripting...

0

Okay.

Make a part called, "Door"

Then go into the green brick and insert a click detector

Put a script into the click detector and put in this script:

door = game.Workspace.Door

function Clicked(Plr)
door.Transparency = 1
door.CanCollide = false
end

script.Parent.MouseClick:connect(Clicked)

Then go into the red brick and put in a click detector, then into that a script.

In the script put:

door = game.Workspace.Door

function Clicked(Plr)
door.Transparency = 0
door.CanCollide = true
end

script.Parent.MouseClick:connect(Clicked)

If you do it right it should open and close the door

well first to change the color on click you would need to do something like this ( ALSO YOU NEED TO ADD A CLICK THING TO IT FOR THIS TO WORK)

function onClicked(OnPlayerClicked)
script.Parent.BrickColor = BrickColor.red()
wait(4.0)
end
some.click.ammount:Connect

That is a way and it is not a very good way either (note: you need to have the brick green) There are many faults there some of this is good but I Forgot the Click Values thing ( P.S. Im new to scripting to) (P.P.S. You do get Better at it ( Trust me ) )

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