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

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

Asked by 3 years ago

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

0
use clickdetector Friskyman321 121 — 3y

1 answer

Log in to vote
1
Answered by
CedCed6 32
3 years ago

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

Ad

Answer this question