Proximity Promt that only a certain group rank or above can use

Hello! So, I’m trying to make a door with a proximity promt, and have been super successful so far, (for my first time trying them). However, I can’t figure out how to make it so only a certain group rank can only open the door. I’ve searched all around the developer fourm, and tried youtube, most everything. No one seems to be able to help. Can anyone here help? Here’s my script so far that allows me to open the door, wait for a certain amount of time, then it closes.

In short:
I need help making it so a certain rank or above in a group can only open a door with a proximity promt.

Script: (Yes, way more than it needs to be however its in a way that makes it harder for glitchers.
game.Workspace.Test.ProximityPrompt.Triggered:Connect(function(player)
*** game.Workspace.Door1.Part1.CanCollide = false***
*** game.Workspace.Door1.Part2.CanCollide = false***
*** game.Workspace.Door1.Part3.CanCollide = false***
*** game.Workspace.Door1.Part4.CanCollide = false***
*** game.Workspace.Door1.Part5.CanCollide = false***
*** game.Workspace.Door1.Part6.CanCollide = false***
*** game.Workspace.Door1.Part7.CanCollide = false***
*** game.Workspace.Door1.Part8.CanCollide = false***
*** game.Workspace.Door1.Part9.CanCollide = false***
*** game.Workspace.Door1.Part10.CanCollide = false***
*** game.Workspace.Door1.Part11.CanCollide = false***
*** game.Workspace.Door1.Part12.CanCollide = false***
*** game.Workspace.Door1.Part13.CanCollide = false***
*** game.Workspace.Door1.Part14.CanCollide = false***
*** game.Workspace.Door1.Part15.CanCollide = false***
*** game.Workspace.Door1.Part16.CanCollide = false***
*** game.Workspace.Door1.Part17.CanCollide = false***
*** game.Workspace.Door1.Part18.CanCollide = false***
*** game.Workspace.Door1.Part19.CanCollide = false***
*** game.Workspace.Door1.Part20.CanCollide = false***
*** game.Workspace.Door1.Part21.CanCollide = false***
*** game.Workspace.Door1.Part22.CanCollide = false***
*** game.Workspace.Door1.Part23.CanCollide = false***
*** game.Workspace.Door1.Part24.CanCollide = false***
*** game.Workspace.Door1.Part25.CanCollide = false***
*** game.Workspace.Door1.Part26.CanCollide = false***
*** game.Workspace.Door1.Part27.CanCollide = false***
*** game.Workspace.Door1.Part28.CanCollide = false***
*** game.Workspace.Door1.Part29.CanCollide = false***
*** game.Workkspace.Door1.Part30.CanCollide = false***


*** print(“Opened!”)***
*** wait(20)***
*** game.Workspace.Door1.Part1.CanCollide = true***
*** game.Workspace.Door1.Part2.CanCollide = true***
*** game.Workspace.Door1.Part3.CanCollide = true***
*** game.Workspace.Door1.Part4.CanCollide = true***
*** game.Workspace.Door1.Part5.CanCollide = true***
*** game.Workspace.Door1.Part6.CanCollide = true***
*** game.Workspace.Door1.Part7.CanCollide = true***
*** game.Workspace.Door1.Part8.CanCollide = true***
*** game.Workspace.Door1.Part9.CanCollide = true***
*** game.Workspace.Door1.Part10.CanCollide = true***
*** game.Workspace.Door1.Part11.CanCollide = true***
*** game.Workspace.Door1.Part12.CanCollide = true***
*** game.Workspace.Door1.Part13.CanCollide = true***
*** game.Workspace.Door1.Part14.CanCollide = true***
*** game.Workspace.Door1.Part15.CanCollide = true***
*** game.Workspace.Door1.Part16.CanCollide = true***
*** game.Workspace.Door1.Part17.CanCollide = true***
*** game.Workspace.Door1.Part18.CanCollide = true***
*** game.Workspace.Door1.Part19.CanCollide = true***
*** game.Workspace.Door1.Part20.CanCollide = true***
*** game.Workspace.Door1.Part21.CanCollide = true***
*** game.Workspace.Door1.Part22.CanCollide = true***
*** game.Workspace.Door1.Part23.CanCollide = true***
*** game.Workspace.Door1.Part24.CanCollide = true***
*** game.Workspace.Door1.Part25.CanCollide = true***
*** game.Workspace.Door1.Part26.CanCollide = true***
*** game.Workspace.Door1.Part27.CanCollide = true***
*** game.Workspace.Door1.Part28.CanCollide = true***
*** game.Workspace.Door1.Part29.CanCollide = true***
*** game.Workspace.Door1.Part30.CanCollide = true***
*** print(“Closed.”)***
end)

3 Likes

Use Player:GetRankInGroup(groupId) and compare using >= operator. The n is any number within 255.

Player:GetRankInGroup(groupId) >= n

Now when you have the comparison, add that to an if statement.


Another thing, but trivial, to mention is how you can cut down your lines by using a for loop:

-- this example will set all collisions of the Door1 model's parts to true
for _, part in pairs(game.Workspace.Door1:GetChildren()) do
    part.CanCollide = true
end
6 Likes

What the. Use collection service. Please dude.

2 Likes

I’m not a scripter. I build and do most everything else.

2 Likes

its simple just use it for the love of god

2 Likes

I only advise to use CollectionService whether a game has multiple doors. In this case, it’s a detailed door model. If we actually tried to expand the idea into CollectionService, it is overcomplicated and does more than what is enough.

3 Likes

If you make a local script which sets the Enabled property to false if the player is not of the correct rank, then have another check in the .Triggered function of the server script to stop hackers enabling and firing it.

1 Like