SpawnLocations, or "spawns" determine where a Player respawns when they die. They can be configured to allow only certain players to use each spawn, using Teams. They also control how ForceFields are set up for newly-spawned players.
SpawnLocations can be used as checkpoints, such as in an obstacle course, using the SpawnLocation.AllowTeamChangeOnTouch property, so that when a player touches it, they will change teams to the SpawnLocation's team. In this case, only the first Team should have Team.AutoAssignable set to true, else players will not start at the first checkpoint.
Note if a SpawnLocation is added to the Workspace in Studio with SpawnLocation.Neutral set to false a Team will be created corresponding to SpawnLocation.TeamColor if it does not already exist. This behavior does not occur when spawns are created in-game using a Script or if the properties of the SpawnLocation are changed after already being added. It is recommended that developers always set up their teams manually and not rely on this behavior.
There are several rules that come into play for a given SpawnLocation when a player respawns:
- If multiple eligible spawns are available to a Player, a random one will be chosen
- Players will spawn at different points on top of a SpawnLocation, but currently, they may still spawn on top of each other if they spawn right after one and other
- If you'd like to configure how long it takes for a player to respawn, take a look at the RespawnTime property
1local Teams = game:GetService("Teams")23-- create start team (AutoAssignable = true)4local startTeam = Instance.new("Team")5startTeam.Name = "Start"6startTeam.AutoAssignable = true7startTeam.TeamColor = BrickColor.new("White")8startTeam.Parent = Teams910-- create checkpoint teams (Autoassignable = false), ensuring all TeamColors are unique11local team1 = Instance.new("Team")12team1.Name = "Checkpoint 1"13team1.AutoAssignable = false14team1.TeamColor = BrickColor.new("Bright blue")15team1.Parent = Teams1617local team2 = Instance.new("Team")18team2.Name = "Checkpoint 2"19team2.AutoAssignable = false20team2.TeamColor = BrickColor.new("Bright green")21team2.Parent = Teams2223local team3 = Instance.new("Team")24team3.Name = "Checkpoint 2"25team3.AutoAssignable = false26team3.TeamColor = BrickColor.new("Bright red")27team3.Parent = Teams2829-- create spawns30local startSpawn = Instance.new("SpawnLocation")31startSpawn.Anchored = true32startSpawn.Size = Vector3.new(5, 1, 5)33startSpawn.Neutral = false34startSpawn.AllowTeamChangeOnTouch = false35startSpawn.TeamColor = startTeam.TeamColor36startSpawn.BrickColor = startTeam.TeamColor37startSpawn.Parent = game.Workspace3839local team1Spawn = Instance.new("SpawnLocation")40team1Spawn.Anchored = true41team1Spawn.Size = Vector3.new(5, 1, 5)42team1Spawn.Neutral = false43team1Spawn.AllowTeamChangeOnTouch = true44team1Spawn.TeamColor = team1.TeamColor45team1Spawn.BrickColor = team1.TeamColor46team1Spawn.Parent = game.Workspace4748local team2Spawn = Instance.new("SpawnLocation")49team2Spawn.Anchored = true50team2Spawn.Size = Vector3.new(5, 1, 5)51team2Spawn.Neutral = false52team2Spawn.AllowTeamChangeOnTouch = true53team2Spawn.TeamColor = team2.TeamColor54team2Spawn.BrickColor = team2.TeamColor55team2Spawn.Parent = game.Workspace5657local team3Spawn = Instance.new("SpawnLocation")58team3Spawn.Anchored = true59team3Spawn.Size = Vector3.new(5, 1, 5)60team3Spawn.Neutral = false61team3Spawn.AllowTeamChangeOnTouch = true62team3Spawn.TeamColor = team3.TeamColor63team3Spawn.BrickColor = team3.TeamColor64team3Spawn.Parent = game.Workspace6566-- position spawns67startSpawn.CFrame = CFrame.new(0, 0.5, 0)68team1Spawn.CFrame = CFrame.new(10, 0.5, 0)69team2Spawn.CFrame = CFrame.new(20, 0.5, 0)70team3Spawn.CFrame = CFrame.new(30, 0.5, 0)
Allows a Player to join the team by touching the SpawnLocation. When set to true, if a Player character comes into contact with the SpawnLocation, the player's Player.TeamColor will be set to SpawnLocation.TeamColor. Player.Neutral will also be set to SpawnLocation.Neutral upon contact, meaning a player can also become neutral by touching a spawn location.
This will not function when SpawnLocation.Enabled is set to false.
This feature is often used to make checkpoints in obstacle courses or similar games.
The length of time, in seconds, that a ForceField will be applied to a Player character spawning at this SpawnLocation. If Duration is zero, the ForceField is never created, and it will not trigger the Instance.DescendantAdded or Instance.ChildAdded events.
This default value of this property is 10 seconds.
The duration feature allows developers to easily give Players protection from 'spawn killing' which can be a frustrating experience for players. Note, ForceFields will only protect users from Explosions and Weapons that use Humanoid:TakeDamage() to deal damage or otherwise check for a ForceField.
This property provides the most convenient way of preventing Players from spawning at a spawn.
The TeamColor property sets what team the SpawnLocation is affiliated to. If SpawnLocation.Neutral property is false, only Players with the same Player.TeamColor as the spawn's TeamColor will be able to spawn there.