How to make it do that?
How to make a door open when i click?
5 answers
step one: Insert ClickDetector object in part
step two: Insert script in ClickDetector
step three: Insert the following code in the script
door = script.Parent.Parent
script.Parent.MouseClick:connect(function()
if door.CanCollide == true then
door.CanCollide = false
else
door.CanCollide = true
end
end)
(This is the modified script of my GUI-controlled door)
- Make a button and insert ClickDetector into it.
- Insert a script into the button.
- Enter the following script
local trigger = script.Parent
local gate = game.Workspace.Door
moving = false
open = false
function onClick()
if open == false and moving == false then
moving = true
script.Parent.BrickColor = "Bright red"
for i = 1, (gate.Size.Y * 10 + 1) do
wait()
gate.CFrame = gate.CFrame*CFrame.new(0, -0.1, 0)
end
moving = false
open = true
elseif open == true and moving == false then
moving = true
script.Parent.Text = "Bright green"
for i = 1, (gate.Size.Y * 10 + 1) do
wait()
gate.CFrame = gate.CFrame*CFrame.new(0, 0.1, 0)
end
moving = false
open = false
end
end
script.Parent.MouseButton1Down:connect(onClick)
- Edit the script into your needs
- Insert the part you want to open and name it "Door" (6) Rate up.
1 comment
good
Step One: Insert ClickDetector object in part
step two: Insert script in ClickDetector
step three: Insert the following code in the script
door = script.Parent.Parent
script.Parent.MouseClick:connect(function()
if door.CanCollide == true then
door.CanCollide = false
else
door.CanCollide = true
end
end)
10 Just tested it, it should work if you followed the directions :). Make sure to upvote :D loriese
1 local door=script.Parent 2 local cd=door:findFirstChild("ClickDetector")or Instance.new("ClickDetector",door) 3 cd.MouseClick:connect(function() 4 door.CanCollide=not door.CanCollide 5 door.Transparency=door.CanCollide and 0 or .5 6 end)
Step 1: add the "ClickDetector"
Step 2:add the script
Step 3:put the code on the script
Hope it works
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Just tested it, it should work if you followed the directions :). Make sure to upvote :D