Class · inherits Part
SpawnLocation
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.
About SpawnLocation
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.
Spawning Rules
There are several rules that come into play for a given SpawnLocation when a player respawns:
- When
SpawnLocation.Neutralis set to false onlyPlayerswithPlayer.TeamColormatchingSpawnLocation.TeamColorwill respawn above it - When
SpawnLocation.Neutralis set to true any Player can spawn above it regardless ofSpawnLocation.TeamColor - 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
See also:
- If you'd like to configure how long it takes for a player to respawn, take a
look at the
RespawnTimeproperty
Properties 5
AllowTeamChangeOnTouch
: booleanAllows aPlayerto join the team by touching theSpawnLocation. When set to true, if aPlayercharacter comes into contact with theSpawnLocation, the player'sPlayer.TeamColorwill be set toSpawnLocation.TeamColor.Allows a
Playerto join the team by touching theSpawnLocation. When set to true, if aPlayercharacter comes into contact with theSpawnLocation, the player'sPlayer.TeamColorwill be set toSpawnLocation.TeamColor.Player.Neutralwill also be set toSpawnLocation.Neutralupon contact, meaning a player can also become neutral by touching a spawn location.This will not function when
SpawnLocation.Enabledis set to false.Making Checkpoints
This feature is often used to make checkpoints in obstacle courses or similar games.
Duration
: intThe length of time, in seconds, that aForceFieldwill be applied to aPlayercharacter spawning at thisSpawnLocation. If Duration is zero, theForceFieldis never created, and it will not trigger theInstance.DescendantAddedorInstance.ChildAddedevents.The length of time, in seconds, that a
ForceFieldwill be applied to aPlayercharacter spawning at thisSpawnLocation. If Duration is zero, theForceFieldis never created, and it will not trigger theInstance.DescendantAddedorInstance.ChildAddedevents.This default value of this property is 10 seconds.
The duration feature allows developers to easily give
Playersprotection from 'spawn killing' which can be a frustrating experience for players. Note,ForceFieldswill only protect users fromExplosionsand weapons that useHumanoid.TakeDamageto deal damage or otherwise check for aForceField.Enabled
: booleanSets whether or not theSpawnLocationis enabled. When disabled players cannot spawn at theSpawnLocationand the AllowTeamChangeOnTouch functionality is disabled.Sets whether or not the
SpawnLocationis enabled. When disabled players cannot spawn at theSpawnLocationand theSpawnLocation.AllowTeamChangeOnTouchfunctionality is disabled.This property provides the most convenient way of preventing
Playersfrom spawning at a spawn.Note, although team changing on touch using
SpawnLocation.AllowTeamChangeOnTouchis disabled when Enabled is set to false, other touched events usingBasePart.Touchedwill still fire.Neutral
: booleanWhether or not aSpawnLocationis affiliated with a specific team. This means that anyPlayer, of anyTeam, can spawn on it if this property is set to true.Whether or not a spawn is affiliated with a specific team. This means that any
Player, of anyTeam, can spawn on it if this property is set to true.If Neutral is set to false, only players whose
Player.TeamColoris equal toSpawnLocation.TeamColorcan use theSpawnLocation.If
SpawnLocation.AllowTeamChangeOnTouchis truePlayer.Neutralwill be set to this property upon contact with the spawn.TeamColor
: BrickColorSets what team theSpawnLocationis affiliated to. IfSpawnLocation.Neutralproperty is false, onlyPlayerswith the samePlayer.TeamColoras the spawn's TeamColor will be able to spawn there.The TeamColor property sets what team the
SpawnLocationis affiliated to. IfSpawnLocation.Neutralproperty is false, onlyPlayerswith the samePlayer.TeamColoras the spawn's TeamColor will be able to spawn there.If
SpawnLocation.AllowTeamChangeOnTouchis truePlayer.Neutralwill be set to this property upon contact with the spawn.
SpawnLocation also has every member of Part. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.