- Create a table with the PlayerIDs of the players you want to enter the staff room
I’ll use the ZonePlus module to allow better hit registrations. You may wish to add it to your game if you choose to use this code: ZonePlus v3.2.0 | Construct dynamic zones and effectively determine players and parts within their boundaries - Place this code into a Local Script in StarterPlayerScripts
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local container = game:GetService("Workspace").CheckPart
local allowpart = game:GetService("Workspace").AllowPart
local zone = Zone.new(container)
local allowedplayers = {} -- enter player user IDs here. Separate with commas.
zone.playerEntered:Connect(function(plr)
local check = table.find(allowedplayers, plr.UserId)
if check ~= nil then
allowpart.CanCollide = false
else
allowpart.CanCollide = true
end
end)
CheckPart is a large, invisible, uncollidable part placed in front of Allowpart. It must have CanQuery on.
AllowPart is the door to the staff room.