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

How can I make a door that only players in a certain group can open?

I need a door that will, when touched, open if they're in a specific group. How do I do this? If you can answer it, then please leave me a script and leave comments so I know what to do!

5 comments

0

Are you making some sort of cafe? If so, I think it is better to make the part uncollideable once the player joins.

0

No; a Research Base

0

Use player:IsInGroup()

0

Are there certain ranks that are allowed to use the door or just everyone in the group?

0

Everybody

1 answer

✓ Accepted answer

One of these scripts goes inside of a LocalScript. The LocalScirpt should then go into StarterPlayerScripts. Both scripts just loop through the PartLocations table and makes the parts uncollide, this only happens locally.

This script shows you how you would use GetRankInGroup(). Documentation about this can be found here https://developer.roblox.com/en-us/api-reference/function/Player/GetRankInGroup

local PartLocation = { -- Insert the paths to the parts in this table
	
}

--[[Example Table
local PartLocation = { 
	workspace.Part,
	workspace.Part2
}
--]]

local GroupID = 1 -- Your GroupID
local RanksAllowed = 2 -- Everything above the rank of 2 in the group can use the door

local PlayerService = game:GetService("Players")
local Client = PlayerService.LocalPlayer

for index, part in pairs(PartLocation) do
	if Client:GetRankInGroup(GroupID) >= RanksAllowed then
		part.CanCollide = false
	end
end

If that isn't what you meant then perhaps you meant anyone inside of the group? If that is the case we will be using IsInGroup() https://developer.roblox.com/en-us/api-reference/function/Player/IsInGroup

local PartLocation = { -- Insert the paths to the parts in this table
	
}

--[[Example Table
local PartLocation = { 
	workspace.Part,
	workspace.Part2
}
--]]

local GroupID = 1 -- Your GroupID

local PlayerService = game:GetService("Players")
local Client = PlayerService.LocalPlayer

for index, part in pairs(PartLocation) do
	if Client:IsInGroup(GroupID) then
		part.CanCollide = false
	end
end

1 comment

0

Thanks! This helped a lot!

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