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

Click detector is not working on door script?

Asked by 4 years ago
local door1 = script.Parent.L1
local door2 = script.Parent.NeonL
local door3 = script.Parent.R1
local door4 = script.Parent.NeonR

local ret1 = door1.CFrame
local ret2 = door2.CFrame
local ret3 = door3.CFrame
local ret4 = door4.CFrame

local look1 = ret1.lookVector
local look2 = ret2.lookVector
local look3 = ret3.lookVector
local look4 = ret4.lookVector




-- Misc
local r = game:GetService("RunService")

local Click1 = script.Parent.Click

local debounce = false


function openDoor1()
    for i=0,math.pi*2,math.pi/100 do
        r.Stepped:wait()
            door1.CFrame=ret1+Vector3.new(-2.1,0,-2.1)*look1-math.cos(i)*-2.1*look1
            door2.CFrame=ret2+Vector3.new(-2.1,0,-2.1)*look2-math.cos(i)*-2.1*look2
            door3.CFrame=ret3+Vector3.new(-2.1,0,-2.1)*look3-math.cos(i)*-2.1*look3
            door4.CFrame=ret4+Vector3.new(-2.1,0,-2.1)*look4-math.cos(i)*-2.1*look4
            if string.format("%3.2f",i)=="3.14" then 
                wait(3) 
            end
        end
    end

function Open()
    door2.BrickColor = BrickColor.new("Lime green")
    door4.BrickColor = BrickColor.new("Lime green")
    Click1.BrickColor = BrickColor.new("Lime green")
end

function Close()
    door2.BrickColor = BrickColor.new("Really red")
    door4.BrickColor = BrickColor.new("Really red")    
    Click1.BrickColor = BrickColor.new("Really red")    
end





Click1.ClickDetector.MouseClick:connect(function(Player)
    if debounce == false and Player:IsInGroup(5177238) and Player:IsInGroup(5173896) and Player:IsInGroup(5173888) and Player:IsInGroup(5175653) and Player:IsInGroup(5173240) and Player:IsInGroup(3621650) >= 16 then 
        debounce = true
        Open()
        openDoor1()
        Close()
        debounce = false
    end
end)

This is for a door and apparently the click detector is not working.

Answer this question