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

How do I make a door where when you click on it, it opens?

I dont know how to script so I need help making a door where when you click on it, it opens.

1 comment

0

use clickdetector

1 answer

✓ Accepted answer

First thing first, insert a Part in the Workspace then rename it Door and thats gonna be the door. Make sure that Anchor and CanCollide is on. Insert a Script and a ClickDetector inside the Part. Then type this in the script:

local Door = script.Parent

local ClickDetector = script.Parent.ClickDetector

local HoverSelectionBox = Instance.new("SelectionBox", Door)
    HoverSelectionBox.Visible = false


local ClickDoorFunction = function()
    Door.CanCollide = not Door.CanCollide

    Door.Transparency = not Door.CanCollide and 0.5 or 0
end


local DoorMouseOver = function()
    HoverSelectionBox.Visible = true
end


local DoorMouseLeave = function()
    HoverSelectionBox.Visible = false
end


ClickDetector.MouseClick:Connect(ClickDoorFunction)

ClickDetector.MouseHoverEnter:Connect(DoorMouseHover)

ClickDetector.MouseHoverLeave:Connect(DoorMouseLeave)


HoverSelectionBox.Adornee = Door

And now your done! Make sure to test it if it works!

If it did not work please comment/reply

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