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

Any ideas on why my animated group rank door isn't working?

Asked by 4 years ago

I am building a game with a secure area that I want to only be operable by people over a certain group rank. I'm quite new to scripting but hopefully, some of you could help me.

local door = script.Parent
local hinge = script.Parent.Hinge
local hingepos = hinge.Position
local tpart = script.Parent.Tpart.ClickDetector
local open = false
local db = false

local ClickDetector = script.Parent.Tpart.ClickDetector
local Debounce = false
ClickDetector.MouseClick:Connect(function(Player)
    if Player:GetRankInGroup(5221697) >= 6 and not Debounce then

Debounce = true

tpart.MouseClick:Connect(function()

if db == false then 
if open == false then
    open = true
db = true

for i = 1, 26, 1 do
door:SetPrimaryPartCFrame(door:GetPrimaryPartCFrame(hingepos) * CFrame.Angles(0,math.rad(3),0,0) * CFrame.new(0,0,0))   
    wait()
end
db = false
elseif open == true and db == false then

for i = 1, 26, 1 do
door:SetPrimaryPartCFrame(door:GetPrimaryPartCFrame(hingepos) * CFrame.Angles(0,math.rad(-3),0,0) * CFrame.new(0,0,0))  
    wait()
open = false
db = true
end
db = false
end
end
end)

 elseif Player:GetRankInGroup(5221697) >= 6 and Debounce then
        Debounce = false
0
What is the code that is coming up error? DiamondMiner199 30 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

I couldn't understand anything in your code, its very messy. Tried to reformat it.

local door = script.Parent
local hinge = script.Parent.Hinge
local hingepos = hinge.Position
local tpart = script.Parent.Tpart.ClickDetector
local open = false
local db = false

local ClickDetector = script.Parent.Tpart.ClickDetector
local Debounce = false
ClickDetector.MouseClick:Connect(function(Player)
    if Player:GetRankInGroup(5221697) >= 6 and not Debounce then

Debounce = true

tpart.MouseClick:Connect(function()

    if db == false then 
        if open == false then
                open = true
            db = true

            for i = 1, 26, 1 do
                door:SetPrimaryPartCFrame(door:GetPrimaryPartCFrame(hingepos) *                 CFrame.Angles(0,math.rad(3),0,0) * CFrame.new(0,0,0))   
                    wait()
            end
            db = false
    elseif open == true and db == false then

        for i = 1, 26, 1 do
            door:SetPrimaryPartCFrame(door:GetPrimaryPartCFrame(hingepos) * CFrame.Angles(0,math.rad(-3),0,0) * CFrame.new(0,0,0))  
             wait()
        end
        open = false
        db = true

    elseif Player:GetRankInGroup(5221697) >= 6 and db then
            db = false
    end
    db = false
    end
end)
Ad

Answer this question