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

How to make a door open when i click?

Asked by 10 years ago

How to make it do that?

5 answers

Log in to vote
1
Answered by
yurhomi10 192
10 years ago

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)
0
Just tested it, it should work if you followed the directions :). Make sure to upvote :D yurhomi10 192 — 10y
Ad
Log in to vote
1
Log in to vote
1
Answered by
Qxest 25
10 years ago

(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.
0
good Loriese 0 — 10y
Log in to vote
0
Answered by 10 years ago

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

Log in to vote
-1
Answered by 10 years ago

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

Answer this question