[HELP!] Working Door

Credits to @Acectix for the working door tutorial Working Door Tutorial

Hey Developers,

I need help making a door where only a certain group rank can enter, but I don’t know where Player:GetRankInGroup() would go.

The code is:

local Door = game.Workspace["The Door"] -- Type the name of your door
local Button = script.Parent
local debounce = false

Button.RedDetector.MouseClick:Connect(function()
		if debounce == false then -- When you click the button turns green and the door opens

		wait(0.3)

		debounce = true
		Door.Transparency = 0.5 -- sets the door to unvisible
		Door.CanCollide = false -- makes the door so you can walk through
		Button.BrickColor = BrickColor.new("Electric Blue")

		Door.Anchored = true -- Ensures the door is anchored
	else -- When clicked again make the buton red ad close the door

		wait(0.3) -- Waiting tim einbetween to prevent spaming

		debounce = false
		Door.Transparency = 0 -- Make the door visible
		Door.CanCollide = true -- Makes the door so you can't walk through it
		Button.BrickColor = BrickColor.new("Really red") -- Set the bricks color
	end

end)

And this is what the explorer looks like:

ggewawaeg

Thanks for your time!

The reason I made this topic/used the script is because I have not found a door that is only a certain group rank can use it

Try to make an if statement that consists the GetRankInGroup function. Something like

if Player:GetRankInGroup(1000) == 1 then

(it is a pseudo line of code, it will not work at all)

So the script becomes

local Door = game.Workspace["The Door"] -- Type the name of your door
local Button = script.Parent
local debounce = false

Button.RedDetector.MouseClick:Connect(function()
	if Player:GetRankInGroup(8423759) then
		if debounce == false then -- When you click the button turns green and the door opens

		wait(0.3)

		debounce = true
		Door.Transparency = 0.5 -- sets the door to unvisible
		Door.CanCollide = false -- makes the door so you can walk through
		Button.BrickColor = BrickColor.new("Electric Blue")

		Door.Anchored = true -- Ensures the door is anchored
	else -- When clicked again make the buton red ad close the door

		wait(0.3) -- Waiting tim einbetween to prevent spaming

		debounce = false
		Door.Transparency = 0 -- Make the door visible
		Door.CanCollide = true -- Makes the door so you can't walk through it
		Button.BrickColor = BrickColor.new("Really red") -- Set the bricks color
	end

end)

BUT the if Player:GetRankInGroup(8423759) then has no rank specifically set, would there be a way to do it like Player:RankInGroup(8423759) == '2' or something

Made a lot of oopsies in the script, sorry.

1 Like

No! There’s no need for a quote if you want to set numbers.

Also, recommend putting the debounce on top of the GetRankInGroup() function. Otherwise, the function will override debounce.

I just realised you edited your post above, is this correct: if Player:GetRankInGroup(1000) == 1 then?

Yes, I realized I made a lot of oopsies in my post. Haven’t really used GetRankInGroup() for a while.

Also, there’s no variable that has Player. It won’t work if there isn’t a variable that says Player.

I didn’t make the script as I am a noob at scripting :joy:
Credits goes to @Acectix for the script

Also how would you make a variable for a player?
Would you do local Player = game.Players?

Honestly, I am a noob at scripting

Correct. You may want to use game:GetService("Players"), but it’s up to you if you want to call services or that.

:white_check_mark: Thanks for all the replies, I am now marking your reply as a solution!