PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Neutral

SpawnLocation

bool

Whether or not a spawn is affiliated with a specific team. This means that any Player, of any Team, can spawn on it if this property is set to true.

If Neutral is set to false, only players whose Player/TeamColor is equal to SpawnLocation/TeamColor can use the SpawnLocation.

If SpawnLocation/AllowTeamChangeOnTouch is true Player/Neutral will be set to this property upon contact with the spawn.


Code Samples


SpawnLocation Checkpoints

This sample demonstrates how SpawnLocations can be used to make a checkpoint system. Typically this would be done Studio and not in Lua, but this example serves as a comprehensive example of what Team and SpawnLocation properties need to be used to achieve this setup.

local Teams = game:GetService("Teams")

-- create start team (AutoAssignable = true)
local startTeam = Instance.new("Team", Teams)
startTeam.Name = "Start"
startTeam.AutoAssignable = true
startTeam.TeamColor = BrickColor.new("White")

-- create checkpoint teams (Autoassignable = false), ensuring all TeamColors are unique
local team1 = Instance.new("Team", Teams)
team1.Name = "Checkpoint 1"
team1.AutoAssignable = false
team1.TeamColor = BrickColor.new("Bright blue")

local team2 = Instance.new("Team", Teams)
team2.Name = "Checkpoint 2"
team2.AutoAssignable = false
team2.TeamColor = BrickColor.new("Bright green")

local team3 = Instance.new("Team", Teams)
team3.Name = "Checkpoint 2"
team3.AutoAssignable = false
team3.TeamColor = BrickColor.new("Bright red")

-- create spawns 
local startSpawn = Instance.new("SpawnLocation", game.Workspace)
startSpawn.Anchored = true
startSpawn.Size = Vector3.new(5, 1, 5)
startSpawn.Neutral = false
startSpawn.AllowTeamChangeOnTouch = false
startSpawn.TeamColor = startTeam.TeamColor
startSpawn.BrickColor = startTeam.TeamColor

local team1Spawn = Instance.new("SpawnLocation", game.Workspace)
team1Spawn.Anchored = true
team1Spawn.Size = Vector3.new(5, 1, 5)
team1Spawn.Neutral = false
team1Spawn.AllowTeamChangeOnTouch = true
team1Spawn.TeamColor = team1.TeamColor
team1Spawn.BrickColor = team1.TeamColor

local team2Spawn = Instance.new("SpawnLocation", game.Workspace)
team2Spawn.Anchored = true
team2Spawn.Size = Vector3.new(5, 1, 5)
team2Spawn.Neutral = false
team2Spawn.AllowTeamChangeOnTouch = true
team2Spawn.TeamColor = team2.TeamColor
team2Spawn.BrickColor = team2.TeamColor

local team3Spawn = Instance.new("SpawnLocation", game.Workspace)
team3Spawn.Anchored = true
team3Spawn.Size = Vector3.new(5, 1, 5)
team3Spawn.Neutral = false
team3Spawn.AllowTeamChangeOnTouch = true
team3Spawn.TeamColor = team3.TeamColor
team3Spawn.BrickColor = team3.TeamColor

-- position spawns
startSpawn.CFrame = CFrame.new(0, 0.5, 0)
team1Spawn.CFrame = CFrame.new(10, 0.5, 0)
team2Spawn.CFrame = CFrame.new(20, 0.5, 0)
team3Spawn.CFrame = CFrame.new(30, 0.5, 0)