Team Only Door Roblox

Posted on

If you have created a game in Roblox, now you may want to make a Team Only Door. You think that you need this door for you game to make your game cooler and also you need it for doing something. You are able to make it after this because we are going to share the methods to you.

We understand that sometimes you want to have doors or forcefields that can be passed through by only certain players and in this case it is your team. For example, a lot of team combat games will spawn player of each team in a safe area that other teams are not able to access it. So, when they spawn or join, they will not be attacked.

If you want to make it, a lot of ways that you can choose but now we are going to show you collision filtering to create doors that can only be passed through by certain team.


Making the Team Only Doors

Now, we are going to make a simple door and the door is basic block parts in the workspace named BlueDoor and RedDoor. The material is Glass and their transparency is set to 0.5. The doors exits in the game world at the beginning of the game, so you are able to set up their collision groups soon. You have to make a Script and paste the code into it in the ServerScriptService. Here is the script.

local PhysicsService = game:GetService(“PhysicsService”)

 ————

local blueDoors = “BlueDoors”

local redDoors = “RedDoors”

 ————–

— Create door collision groups

PhysicsService:CreateCollisionGroup(blueDoors)

PhysicsService:CreateCollisionGroup(redDoors)

————

— Add doors to their proper collision group

PhysicsService:SetPartCollisionGroup(workspace.BlueDoor, blueDoors)

PhysicsService:SetPartCollisionGroup(workspace.RedDoor, redDoors)

Now, you have to add spawning players to an appropriate collision group. A lot of ways to assign individual players to a groups and those are:

  • Assign players a ‘color’ based on their team color.
  • Check if the player has got a special badge or bought a game pass which allow them to access a restricted area.

In this tutorial, we will assign all incoming players to the ‘blue’ team and give them access via the blue door but not the read door.

Now, you have to set up player collision groups by adding the lines below to the script.

— Add doors to their proper collision group

PhysicsService:SetPartCollisionGroup(workspace.BlueDoor, blueDoors)

PhysicsService:SetPartCollisionGroup(workspace.RedDoor, redDoors)

 ————

local bluePlayers = “BluePlayers”

local redPlayers = “RedPlayers”

 ————

— Create player collision groups

PhysicsService:CreateCollisionGroup(bluePlayers)

PhysicsService:CreateCollisionGroup(redPlayers)

When you add players to collision groups, you need to remember that all parts of their character need to be permitted to pass through the door. You can do it with a function that finds all BasePart object, the base class of both Parts and MeshParts which make up the avatar of the player.

To finish this, you need to define the collision groups that do not collide with each other specifically, blue players should not collide with blue doors and red players should not collide with red doors. You are able to see the complete script for this by accessing developer.roblox.com. You can find the script and the complete method in the Collision Filtering Team Doors section.

Leave a Reply

Your email address will not be published. Required fields are marked *