How to make a team barrier

Trying to make a border so the other team cannot enter a certain area. I dont want players spawnkilling people from the other team, ending up with complaints through my message inbox.

Basically so heres an example:
Red team has a base which blue team cannot enter. Technically red team has a barrier which cancollide is true for the players on red team, however blue team will get killed by the barrier.

Ive tried Game:Getservice(“team”) = game.workspace.barrier. If player is on Game.Teams.Blue = cancollide = true

But this code didn’t work.
The barrier is a playerkill brick which is only available to kill certain players on a team, but not the team where the team players are allowed to go through the barrier.

Does anyone know how to do this? I dont want dislikes because of spawnkilling.

1 Like

Let me get this right:

You want a barrier in which one team can walk through, but the other team dies when they touch it?

You mean just like this?

https://developer.roblox.com/en-us/articles/Collision-Filtering-Team-Doors

1 Like

yes, the teammates can walk thriugh the barrier but other teammates cant.

All you need to do is make the cancollide false (not in a script), and just script so when someone touches it it will check what team they are on.

If the player is not on the same team that the barrier is for, then just set the player’s health to 0.

Hope this helps!