Staff Door Scripting Issue?

Are you trying to use an invisible door for the script? Like Transparency set to 1.

Did you check that in the script the Path of the Door is correctly defined? Maybe the Staff Door is not named “Door”. You may want to check it out.

Yes. The door is named “Door” with a capital D. And yes, my staff door is transparent.

Many of you are stating a wrong reason for using a player added function ,you don’t really need to add a player added function, this is simple do like this

local canwork = true
local groupId = 0000

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("HumanoidRootPart") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player:GetRankInGroup(groupId) > 4 and canwork == true then
            canwork = false
            script.Parent.CanCollide = true
            task.wait(1)
            script.Parent.CanCollide = false
            canwork = true
        end
    end
end)

This is how you do it, you don’t actually do player added function ,I would say its a misleading thing to tell others, if your not sure about it

You shouldn’t use folders when your going for a kind of a door, you should go for CollectionService

My personal opinion would be better if you used :Destroy() instead of CanCollide. Even though it’s almost the same, it may work.

local group
local rank
local LocalPlayer = game.Players.LocalPlayer

if LocalPlayer:GetRankInGroup(group) >= rank then 
	local door
	
	door:Destroy()
	print("allowed")
	
else
	print("nope")
end

Try adding values to the variables!

There’s no reason for the script in the original post not to work. Just make sure that: it’s in StarterPlayerScripts and that it references the door properly. Naming a child of an object the same as its parent can cause some referencing issues, to get around this you’d want to do Door[“Door”]. If you want to have more than one staff door, you could put all the doors in a folder and use a for loop or you could use Collection Service. If nothing works in the end, you can contact me in and I’d be happy with taking a look in studio myself to try and fix the problem.

use groupService

local GroupService = game:GetService("GroupService")
local doorPart = script.Parent

local groupId = 10250221
local minimumRank = 4

doorPart.Touched:Connect(function(Player)
	if game.Players:FindFirstChild(Player.Parent.Name) then
		local Playerv2 = game.Players:FindFirstChild(Player.Parent.Name)

		local GroupInfo = GroupService:GetGroupsAsync(Playerv2.UserId)
		print(GroupInfo)
	end
	print("AAAAAAAAAAAAAAAAAA WHY IS NOTHING PRINTING")
end)

ok finished script is:

local GroupService = game:GetService("GroupService")
local doorPart = script.Parent

local groupId = 10250221
local minimumRank = 4

doorPart.Touched:Connect(function(Player)
	if game.Players:FindFirstChild(Player.Parent.Name) then
		local Playerv2 = game.Players:FindFirstChild(Player.Parent.Name)

		local GroupInfo = GroupService:GetGroupsAsync(Playerv2.UserId)
		
		
		for i, Groups in pairs(GroupInfo) do
			if Groups.Id == groupId then
				if Groups.Rank >= minimumRank then
					doorPart.Transparency = 1
					doorPart.CanCollide = false
				end
			end
		end
	end
end)

Ye, i tested it and it works yay

Edit:

Wait nvm its not local script so it will be transparent to all players AAAAAAAAAAA

ok you can just use RemoteEvents

Hey, are you still experiencing issues? I can send you over a script/feedback that may help you more.

I’m keeping it basic as I don’t want to explain how CollectionService works.

The way I showed is simple and easier to understand. Inserting the script in every door isn’t ideal, and they’d also be using a normal script, which would mean when the door is uncollided via the normal script, it’s uncollided for even those who aren’t authorized to go in the area. This is why I recommend using the method I showed, and if you know CollectionService you can easily implement it on your own.