RB-004
Roblox team-only door script
A door that only opens for players on one team.
- Script type
- Script
- Where it goes
- Inside the door Part
- Category
- Doors and interaction
For your own game in Roblox Studio. Not for use in other people's games.
The code
-- Team-only door: opens briefly when a member of the right team touches it.
local TEAM_NAME = "Red" -- the exact name of the team in the Teams service
local OPEN_TIME = 2 -- seconds the door stays open
local Players = game:GetService("Players")
local door = script.Parent
local isOpen = false
door.Touched:Connect(function(hit)
if isOpen then
return
end
local player = Players:GetPlayerFromCharacter(hit.Parent)
if not player or not player.Team then
return
end
if player.Team.Name ~= TEAM_NAME then
return
end
isOpen = true
door.CanCollide = false
door.Transparency = 0.7
task.wait(OPEN_TIME)
door.CanCollide = true
door.Transparency = 0
isOpen = false
end)How to set it up
- In the Explorer, find Teams. Click the plus button and add a Team. Name it Red and pick a TeamColor.
- Add a second Team (for example Blue). Add a SpawnLocation for each team and set its TeamColor and Neutral = false.
- Insert a Part for the door, set Anchored to true, and add a Script to it with the code.
- Play. Players on Red can walk through. Players on Blue cannot.
Change it
- TEAM_NAME must match the Team name exactly, including capital letters.
- Players with no team (neutral) are never let through.
- This opens the door for everyone nearby while it is open. For a strict one-person gate, use collision groups.
More in Doors and interaction
More Roblox tools
- Shirt and pants templatesFree Roblox clothing templates to download: hoodies, jerseys, jeans, joggers and more.
- Robux tax calculatorWork out what you receive after the marketplace fee, or what to charge.
- Robux to USD calculatorConvert earned Robux to dollars at a DevEx rate you can edit.
- Shirt and pants template makerColour each panel of the 585×559 clothing template and download it.
- Username generatorGenerate usernames that fit the 3–20 character rule.