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:

See also:

  • If you'd like to configure how long it takes for a player to respawn, take a look at the RespawnTime property

コードサンプル

SpawnLocation Checkpoints

local Teams = game:GetService("Teams")
-- create start team (AutoAssignable = true)
local startTeam = Instance.new("Team")
startTeam.Name = "Start"
startTeam.AutoAssignable = true
startTeam.TeamColor = BrickColor.new("White")
startTeam.Parent = Teams
-- create checkpoint teams (Autoassignable = false), ensuring all TeamColors are unique
local team1 = Instance.new("Team")
team1.Name = "Checkpoint 1"
team1.AutoAssignable = false
team1.TeamColor = BrickColor.new("Bright blue")
team1.Parent = Teams
local team2 = Instance.new("Team")
team2.Name = "Checkpoint 2"
team2.AutoAssignable = false
team2.TeamColor = BrickColor.new("Bright green")
team2.Parent = Teams
local team3 = Instance.new("Team")
team3.Name = "Checkpoint 2"
team3.AutoAssignable = false
team3.TeamColor = BrickColor.new("Bright red")
team3.Parent = Teams
-- create spawns
local startSpawn = Instance.new("SpawnLocation")
startSpawn.Anchored = true
startSpawn.Size = Vector3.new(5, 1, 5)
startSpawn.Neutral = false
startSpawn.AllowTeamChangeOnTouch = false
startSpawn.TeamColor = startTeam.TeamColor
startSpawn.BrickColor = startTeam.TeamColor
startSpawn.Parent = game.Workspace
local team1Spawn = Instance.new("SpawnLocation")
team1Spawn.Anchored = true
team1Spawn.Size = Vector3.new(5, 1, 5)
team1Spawn.Neutral = false
team1Spawn.AllowTeamChangeOnTouch = true
team1Spawn.TeamColor = team1.TeamColor
team1Spawn.BrickColor = team1.TeamColor
team1Spawn.Parent = game.Workspace
local team2Spawn = Instance.new("SpawnLocation")
team2Spawn.Anchored = true
team2Spawn.Size = Vector3.new(5, 1, 5)
team2Spawn.Neutral = false
team2Spawn.AllowTeamChangeOnTouch = true
team2Spawn.TeamColor = team2.TeamColor
team2Spawn.BrickColor = team2.TeamColor
team2Spawn.Parent = game.Workspace
local team3Spawn = Instance.new("SpawnLocation")
team3Spawn.Anchored = true
team3Spawn.Size = Vector3.new(5, 1, 5)
team3Spawn.Neutral = false
team3Spawn.AllowTeamChangeOnTouch = true
team3Spawn.TeamColor = team3.TeamColor
team3Spawn.BrickColor = team3.TeamColor
team3Spawn.Parent = game.Workspace
-- 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)

概要

プロパティ

Part から継承した プロパティ
  • 複製されていません
    並列読み取り

    Sets the overall shape of the object.

BasePart から継承した プロパティ
  • 並列読み取り

    Determines whether a part is immovable by physics.

  • 複製されていません
    並列読み取り

    The angular velocity of the part's assembly.

  • 読み取り専用
    複製されていません
    並列読み取り

    The center of mass of the part's assembly in world space.

  • 複製されていません
    並列読み取り

    The linear velocity of the part's assembly.

  • 読み取り専用
    複製されていません
    並列読み取り

    The total mass of the part's assembly.

  • 読み取り専用
    複製されていません
    並列読み取り

    A reference to the root part of the assembly.

  • 並列読み取り

    Determines the type of surface for the Back face of a part (+Z direction).

  • Determines the type of surface for the Bottom face of a part (-Y direction).

  • 複製されていません
    並列読み取り

    Determines the color of a part.

  • 並列読み取り

    Determines the position and orientation of the BasePart in the world.

  • 並列読み取り

    Determines whether a part may collide with other parts.

  • 並列読み取り

    Determines whether the part is considered during spatial query operations.

  • 並列読み取り

    Determines if Touched and TouchEnded events fire on the part.

  • 並列読み取り

    Determines whether or not a part casts a shadow.

  • 読み取り専用
    複製されていません
    並列読み取り

    Describes the world position in which a part's center of mass is located.

  • 複製されていません
    並列読み取り

    Describes the name of a part's collision group.

  • 複製されていません
    並列読み取り

    Determines the color of a part.

  • 読み取り専用
    複製されていません
    並列読み取り

    Indicates the current physical properties of the part.

  • Determines several physical properties of a part.

  • 並列読み取り

    Used to enable or disable aerodynamic forces on parts and assemblies.

  • 読み取り専用
    複製されていません
    並列読み取り

    The CFrame of the physical extents of the BasePart.

  • 読み取り専用
    複製されていません
    並列読み取り

    The actual physical size of the BasePart as regarded by the physics engine.

  • 並列読み取り

    Determines the type of surface for the Front face of a part (-Z direction).

  • 並列読み取り

    Determines the type of surface for the Left face of a part (-X direction).

  • 非表示
    複製されていません
    並列読み取り

    Determines a multiplier for BasePart.Transparency that is only visible to the local client.

  • 並列読み取り

    Determines whether a part is selectable in Studio.

  • 読み取り専用
    複製されていません
    並列読み取り

    Describes the mass of the part, the product of its density and volume.

  • 並列読み取り

    Determines whether the part contributes to the total mass or inertia of its rigid body.

  • 並列読み取り

    Determines the texture and default physical properties of a part.

  • 複製されていません
    並列読み取り

    The name of MaterialVariant.

  • 非表示
    複製されていません
    並列読み取り

    Describes the rotation of the part in the world.

  • 並列読み取り

    Specifies the offset of the part's pivot from its CFrame.

  • 非表示
    複製されていません
    並列読み取り

    Describes the position of the part in the world.

  • 非表示
    読み取り専用
    複製されていません
    並列読み取り

    Time since last recorded physics update.

  • 並列読み取り

    Determines how much a part reflects the skybox.

  • 読み取り専用
    複製されていません
    並列読み取り

    Describes the smallest change in size allowable by the Resize method.

  • 読み取り専用
    複製されていません
    並列読み取り

    Describes the faces on which a part may be resized.

  • 並列読み取り

    Determines the type of surface for the Right face of a part (+X direction).

  • 並列読み取り

    The main rule in determining the root part of an assembly.

  • 複製されていません
    並列読み取り

    The rotation of the part in degrees for the three axes.

  • 複製されていません
    並列読み取り

    Determines the dimensions of a part (length, width, height).

  • 並列読み取り

    Determines the type of surface for the Top face of a part (+Y direction).

  • 並列読み取り

    Determines how much a part can be seen through (the inverse of part opacity).

PVInstance から継承した プロパティ
  • 複製されていません
    スクリプト作成できません
    並列読み取り
  • 複製されていません
    スクリプト作成できません
    並列読み取り

方法

BasePart から継承した 方法PVInstance から継承した 方法

イベント

BasePart から継承した イベント

プロパティ

AllowTeamChangeOnTouch

並列読み取り

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.

コードサンプル

SpawnLocation Checkpoints

local Teams = game:GetService("Teams")
-- create start team (AutoAssignable = true)
local startTeam = Instance.new("Team")
startTeam.Name = "Start"
startTeam.AutoAssignable = true
startTeam.TeamColor = BrickColor.new("White")
startTeam.Parent = Teams
-- create checkpoint teams (Autoassignable = false), ensuring all TeamColors are unique
local team1 = Instance.new("Team")
team1.Name = "Checkpoint 1"
team1.AutoAssignable = false
team1.TeamColor = BrickColor.new("Bright blue")
team1.Parent = Teams
local team2 = Instance.new("Team")
team2.Name = "Checkpoint 2"
team2.AutoAssignable = false
team2.TeamColor = BrickColor.new("Bright green")
team2.Parent = Teams
local team3 = Instance.new("Team")
team3.Name = "Checkpoint 2"
team3.AutoAssignable = false
team3.TeamColor = BrickColor.new("Bright red")
team3.Parent = Teams
-- create spawns
local startSpawn = Instance.new("SpawnLocation")
startSpawn.Anchored = true
startSpawn.Size = Vector3.new(5, 1, 5)
startSpawn.Neutral = false
startSpawn.AllowTeamChangeOnTouch = false
startSpawn.TeamColor = startTeam.TeamColor
startSpawn.BrickColor = startTeam.TeamColor
startSpawn.Parent = game.Workspace
local team1Spawn = Instance.new("SpawnLocation")
team1Spawn.Anchored = true
team1Spawn.Size = Vector3.new(5, 1, 5)
team1Spawn.Neutral = false
team1Spawn.AllowTeamChangeOnTouch = true
team1Spawn.TeamColor = team1.TeamColor
team1Spawn.BrickColor = team1.TeamColor
team1Spawn.Parent = game.Workspace
local team2Spawn = Instance.new("SpawnLocation")
team2Spawn.Anchored = true
team2Spawn.Size = Vector3.new(5, 1, 5)
team2Spawn.Neutral = false
team2Spawn.AllowTeamChangeOnTouch = true
team2Spawn.TeamColor = team2.TeamColor
team2Spawn.BrickColor = team2.TeamColor
team2Spawn.Parent = game.Workspace
local team3Spawn = Instance.new("SpawnLocation")
team3Spawn.Anchored = true
team3Spawn.Size = Vector3.new(5, 1, 5)
team3Spawn.Neutral = false
team3Spawn.AllowTeamChangeOnTouch = true
team3Spawn.TeamColor = team3.TeamColor
team3Spawn.BrickColor = team3.TeamColor
team3Spawn.Parent = game.Workspace
-- 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)

Duration

並列読み取り

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.

コードサンプル

SpawnLocation ForceField

local spawnLocation = Instance.new("SpawnLocation")
spawnLocation.Anchored = true
spawnLocation.Size = Vector3.new(5, 1, 5)
spawnLocation.Neutral = true -- anyone can spawn here
spawnLocation.Duration = 20
spawnLocation.Parent = workspace

Enabled

並列読み取り

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.

コードサンプル

SpawnLocation Enabled

local spawnLocation = Instance.new("SpawnLocation")
spawnLocation.Anchored = true
spawnLocation.Size = Vector3.new(5, 1, 5)
spawnLocation.Neutral = true -- anyone can spawn here
spawnLocation.Enabled = true
spawnLocation.Parent = workspace
local function onEnabledChanged()
spawnLocation.Transparency = spawnLocation.Enabled and 0 or 0.5
end
spawnLocation:GetPropertyChangedSignal("Enabled"):Connect(onEnabledChanged)
task.wait(5)
spawnLocation.Enabled = false -- transparency = 0.5

Neutral

並列読み取り

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.

コードサンプル

SpawnLocation Checkpoints

local Teams = game:GetService("Teams")
-- create start team (AutoAssignable = true)
local startTeam = Instance.new("Team")
startTeam.Name = "Start"
startTeam.AutoAssignable = true
startTeam.TeamColor = BrickColor.new("White")
startTeam.Parent = Teams
-- create checkpoint teams (Autoassignable = false), ensuring all TeamColors are unique
local team1 = Instance.new("Team")
team1.Name = "Checkpoint 1"
team1.AutoAssignable = false
team1.TeamColor = BrickColor.new("Bright blue")
team1.Parent = Teams
local team2 = Instance.new("Team")
team2.Name = "Checkpoint 2"
team2.AutoAssignable = false
team2.TeamColor = BrickColor.new("Bright green")
team2.Parent = Teams
local team3 = Instance.new("Team")
team3.Name = "Checkpoint 2"
team3.AutoAssignable = false
team3.TeamColor = BrickColor.new("Bright red")
team3.Parent = Teams
-- create spawns
local startSpawn = Instance.new("SpawnLocation")
startSpawn.Anchored = true
startSpawn.Size = Vector3.new(5, 1, 5)
startSpawn.Neutral = false
startSpawn.AllowTeamChangeOnTouch = false
startSpawn.TeamColor = startTeam.TeamColor
startSpawn.BrickColor = startTeam.TeamColor
startSpawn.Parent = game.Workspace
local team1Spawn = Instance.new("SpawnLocation")
team1Spawn.Anchored = true
team1Spawn.Size = Vector3.new(5, 1, 5)
team1Spawn.Neutral = false
team1Spawn.AllowTeamChangeOnTouch = true
team1Spawn.TeamColor = team1.TeamColor
team1Spawn.BrickColor = team1.TeamColor
team1Spawn.Parent = game.Workspace
local team2Spawn = Instance.new("SpawnLocation")
team2Spawn.Anchored = true
team2Spawn.Size = Vector3.new(5, 1, 5)
team2Spawn.Neutral = false
team2Spawn.AllowTeamChangeOnTouch = true
team2Spawn.TeamColor = team2.TeamColor
team2Spawn.BrickColor = team2.TeamColor
team2Spawn.Parent = game.Workspace
local team3Spawn = Instance.new("SpawnLocation")
team3Spawn.Anchored = true
team3Spawn.Size = Vector3.new(5, 1, 5)
team3Spawn.Neutral = false
team3Spawn.AllowTeamChangeOnTouch = true
team3Spawn.TeamColor = team3.TeamColor
team3Spawn.BrickColor = team3.TeamColor
team3Spawn.Parent = game.Workspace
-- 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)

TeamColor

並列読み取り

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.

コードサンプル

SpawnLocation Checkpoints

local Teams = game:GetService("Teams")
-- create start team (AutoAssignable = true)
local startTeam = Instance.new("Team")
startTeam.Name = "Start"
startTeam.AutoAssignable = true
startTeam.TeamColor = BrickColor.new("White")
startTeam.Parent = Teams
-- create checkpoint teams (Autoassignable = false), ensuring all TeamColors are unique
local team1 = Instance.new("Team")
team1.Name = "Checkpoint 1"
team1.AutoAssignable = false
team1.TeamColor = BrickColor.new("Bright blue")
team1.Parent = Teams
local team2 = Instance.new("Team")
team2.Name = "Checkpoint 2"
team2.AutoAssignable = false
team2.TeamColor = BrickColor.new("Bright green")
team2.Parent = Teams
local team3 = Instance.new("Team")
team3.Name = "Checkpoint 2"
team3.AutoAssignable = false
team3.TeamColor = BrickColor.new("Bright red")
team3.Parent = Teams
-- create spawns
local startSpawn = Instance.new("SpawnLocation")
startSpawn.Anchored = true
startSpawn.Size = Vector3.new(5, 1, 5)
startSpawn.Neutral = false
startSpawn.AllowTeamChangeOnTouch = false
startSpawn.TeamColor = startTeam.TeamColor
startSpawn.BrickColor = startTeam.TeamColor
startSpawn.Parent = game.Workspace
local team1Spawn = Instance.new("SpawnLocation")
team1Spawn.Anchored = true
team1Spawn.Size = Vector3.new(5, 1, 5)
team1Spawn.Neutral = false
team1Spawn.AllowTeamChangeOnTouch = true
team1Spawn.TeamColor = team1.TeamColor
team1Spawn.BrickColor = team1.TeamColor
team1Spawn.Parent = game.Workspace
local team2Spawn = Instance.new("SpawnLocation")
team2Spawn.Anchored = true
team2Spawn.Size = Vector3.new(5, 1, 5)
team2Spawn.Neutral = false
team2Spawn.AllowTeamChangeOnTouch = true
team2Spawn.TeamColor = team2.TeamColor
team2Spawn.BrickColor = team2.TeamColor
team2Spawn.Parent = game.Workspace
local team3Spawn = Instance.new("SpawnLocation")
team3Spawn.Anchored = true
team3Spawn.Size = Vector3.new(5, 1, 5)
team3Spawn.Neutral = false
team3Spawn.AllowTeamChangeOnTouch = true
team3Spawn.TeamColor = team3.TeamColor
team3Spawn.BrickColor = team3.TeamColor
team3Spawn.Parent = game.Workspace
-- 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)

方法

イベント