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

How to make a door open when i click?

How to make it do that?

5 answers

✓ Accepted answer

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)

1 comment

0

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

(This is the modified script of my GUI-controlled door)

  1. Make a button and insert ClickDetector into it.
  2. Insert a script into the button.
  3. 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)
  1. Edit the script into your needs
  2. Insert the part you want to open and name it "Door" (6) Rate up.

1 comment

0

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.