Class
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, 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#
AllowTeamChangeOnTouchboolean | 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.ReadSafe |
Durationint | 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.ReadSafe |
Enabledboolean | Sets whether or not the SpawnLocation is enabled. When disabled
players cannot spawn at the SpawnLocation and the
AllowTeamChangeOnTouch functionality is disabled.ReadSafe |
Neutralboolean | Whether or not a SpawnLocation 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.ReadSafe |
TeamColorBrickColor | 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.ReadSafe |
AllowTeamChangeOnTouch: boolean#
ReadSafe
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.
Making Checkpoints#
This feature is often used to make checkpoints in obstacle courses or similar games.
Duration: int#
ReadSafe
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.
Enabled: boolean#
ReadSafe
Sets whether or not the SpawnLocation is enabled. When disabled
players cannot spawn at the SpawnLocation and the
SpawnLocation.AllowTeamChangeOnTouch functionality is disabled.
This property provides the most convenient way of preventing
Players from spawning at a spawn.
Note, although team changing on touch using
SpawnLocation.AllowTeamChangeOnTouch is disabled when Enabled is
set to false, other touched events using BasePart.Touched will
still fire.
Neutral: boolean#
ReadSafe
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.
TeamColor: BrickColor#
ReadSafe
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.
If SpawnLocation.AllowTeamChangeOnTouch is true
Player.Neutral will be set to this property upon contact with the
spawn.
Inherited members#
Inherited from FormFactorPart 2
Properties (2)
Inherited from BasePart 106
Properties (69)
Anchored, AssemblyAngularVelocity, AssemblyCenterOfMass, AssemblyLinearVelocity, AssemblyMass, AssemblyRootPart, AudioCanCollide, BackParamA, BackParamB, BackSurface, BackSurfaceInput, BottomParamA, BottomParamB, BottomSurface, BottomSurfaceInput, BrickColor, brickColor, CanCollide, CanQuery, CanTouch, CastShadow, CenterOfMass, CFrame, CollisionGroup, CollisionGroupId, Color, CurrentPhysicalProperties, CustomPhysicalProperties, Elasticity, EnableFluidForces, ExtentsCFrame, ExtentsSize, Friction, FrontParamA, FrontParamB, FrontSurface, FrontSurfaceInput, LeftParamA, LeftParamB, LeftSurface, LeftSurfaceInput, LocalTransparencyModifier, Locked, Mass, Massless, Material, MaterialVariant, Orientation, PivotOffset, Position, ReceiveAge, Reflectance, ResizeableFaces, ResizeIncrement, RightParamA, RightParamB, RightSurface, RightSurfaceInput, RootPriority, Rotation, RotVelocity, Size, SpecificGravity, TopParamA, TopParamB, TopSurface, TopSurfaceInput, Transparency, Velocity
Methods (32)
AngularAccelerationToTorque, ApplyAngularImpulse, ApplyImpulse, ApplyImpulseAtPosition, BindToCollisionSummaries, BreakJoints, breakJoints, CanCollideWith, CanSetNetworkOwnership, GetClosestPointOnSurface, GetConnectedParts, GetJoints, GetMass, getMass, GetNetworkOwner, GetNetworkOwnershipAuto, GetNoCollisionConstraints, GetRenderCFrame, GetRootPart, GetTouchingParts, GetVelocityAtPosition, IntersectAsync, IsGrounded, MakeJoints, makeJoints, Resize, resize, SetNetworkOwner, SetNetworkOwnershipAuto, SubtractAsync, TorqueToAngularAcceleration, UnionAsync
Events (5)
LocalSimulationTouched, OutfitChanged, StoppedTouching, Touched, TouchEnded
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild