Ban people for entering a area

You can write your topic however you want, but you need to answer these questions:
I would like to make a banned area were everyone can enter but you can ban some people from entering. (Not like a command like in the script we would just do “user1”, “user2” etc
I am not sure if I can do this or not.

I have looked it up and found nothing.

Not asking for a script. Just asking if I can do this or not and some pointers.

1 Like

You could define your area as a big, colliding, invisible, anchored part.

Then assign players to different collision groups so that some collide with it, but others don’t.

Something like the technique in this article: Collision Filtering | Roblox Creator Documentation

But with specific names instead of teams, probably.

Ok, but like I want EVERYONE to come in this area just not blacklisted people from the area.

well you can make an blacklist and check the player’s model name and see if it is in the blacklist

So make a model called “Blacklist” and then have it respawn “user1”, “user2” etc? Sorry for the late reply.

Right, so make a new collision group. Make it only collide with itself.

  1. Make a “BlacklistArea” group
  2. Make a “BlacklistPlayers” group
  3. Make them collide with each other. Make BlacklistPlayers also collide with everything that Default collides with.

Add the “area part” to the BlacklistArea group
Add the blacklisted players to the BlacklistPlayers group

Done!

For example, given these groups:

image

You could add a part in workspace and do something like this

local players = game:GetService("Players")
local physicsService = game:GetService("PhysicsService")
local area = workspace.Part
physicsService:SetPartCollisionGroup(area, "BlacklistArea")

local banned = {
	["nicemike40"] = true,
	["chrisfs123"] = true,
}

local function addToBlacklistGroup(part)
	if part:IsA("BasePart") then
		physicsService:SetPartCollisionGroup(part, "BlacklistPlayers")
	end
end

local function onCharacterAdded(character)
	for _, part in pairs(character:GetDescendants()) do
		addToBlacklistGroup(part)
	end

	character.DescendantAdded:Connect(addToBlacklistGroup)
end

local function onPlayerAdded(player)
	if banned[player.Name] then
		if player.Character then
			onCharacterAdded(player.Character)
		end
		player.CharacterAdded:Connect(onCharacterAdded)
	end
end

players.PlayerAdded:Connect(onPlayerAdded)
1 Like

(post deleted by author)

So this would be the script? And would I part this in this in the part? And were would I put the user ids.

@chrisfs123 I would recommend using collision group(which is used in the article Restricted/TeamDoors) and fire a event when a player joined where if they are on the black list assign them a black listed collision group

Just make a table of players who cannot walk in the area (data save if you want) then create a Region3 around the area and every so often loop through the players inside the region, and ban them.

No I think he means like Block some people from entering

You could give the players that you want banned a certain value that is saved/given to them. Then you can create a zone by using a part that will check if a player has that value using part.Touched:Connect(function(hit [or whatever you want to call this] ))

Sorry for the late reply but where do I get the Collison Groups Editor?

Click the Collision Groups button () within the Advanced section of the Model tab.

Thank you so much!! Have a good one.