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) 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)
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