Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

What is the code that is coming up error?

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.