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

Open door button script not working. Any help? (This button is for a rank+ only.)

Asked by
ghxstlvty 133
4 years ago
Edited 4 years ago
local ClickDetector = script.Parent.ClickDetector
open = false
LGate2 = script.Parent.LGate2
RGate2 = script.Parent.RGate2
Increment = 180

ClickDetector.MouseClick:Connect(function (player)
    if player:GetRankInGroup(4853203) >= 10 then
        script.Parent.ClickDetector.MouseClick:Connect(function()
    if open == false then
        open = true
        for C = 1, Increment do
            wait()                              
            LGate2.PrimaryPart = LGate2.hinge
            RGate2.PrimaryPart = RGate2.hinge                           
            LGate2:SetPrimaryPartCFrame(LGate2.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0,math.rad(-110/Increment),0))
            RGate2:SetPrimaryPartCFrame(RGate2.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0,math.rad(110/Increment),0))
        end
    elseif open == true then
        open = false
        for C = 1, Increment do
            wait()                              
            LGate2.PrimaryPart = LGate2.hinge
            RGate2.PrimaryPart = RGate2.hinge                               
            LGate2:SetPrimaryPartCFrame(LGate2.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0,math.rad(110/Increment),0))
            RGate2:SetPrimaryPartCFrame(RGate2.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0,math.rad(-110/Increment),0))
        end
    end
end)
    end
end)

My script to open a door isn't working. This is where everything is located: https://prnt.sc/r9rgvp

There are two doors with 1 script each. I have a left and a right door.

2 answers

Log in to vote
0
Answered by 4 years ago

Problems

On line 3 and 4 you said script.Parent.LGate2 and script.Parent.RGate2 and script.Parent is RemotePadInterview and RemotePadTraining

Solution

Replace script.Parent with script.Parent.Parent

Final Script Snippet

local ClickDetector = script.Parent.ClickDetector
open = false
LGate2 = script.Parent.Parent.LGate2
RGate2 = script.Parent.Parent.RGate2
Increment = 180

-- Other code here...
0
Thanks so much! I did this to both scripts but... the interview door isn't working. ghxstlvty 133 — 4y
0
Nevermind, you just have to double click the button and it opens. Thanks for the help! ghxstlvty 133 — 4y
0
No Problem :D Luka_Gaming07 534 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I think that line 9 is stoping it from working. Remove line 9 and the end for it and try again

0
It's saying something about line 3. I did just delete line 9 though. ghxstlvty 133 — 4y

Answer this question