SpawnLocation

Mostrar obsoleto

*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.

Las ubicaciones de spawn, o "spawns", determinan dónde reaparece un Player cuando muere. Pueden configurarse para permitir que solo ciertos jugadores usen cada regeneración, usando Teams . También controlan cómo se configuran los ForceFields para los jugadores recién nacidos.

Las ubicaciones de spawn se pueden usar como puntos de control, como en un obstáculo, usando la propiedad SpawnLocation.AllowTeamChangeOnTouch, para que cuando un jugador toque el obstáculo, cambie de equipo al equipo de la ubicación de spawn. En este caso, solo la primera Team debería tener Team.AutoAssignable

Nota si se agrega una SpawnLocation a la Workspace en Studio con SpawnLocation.Neutral configurado para false un Equipo se creará correspondiente a SpawnLocation.TeamColor si no ya existe. Este comportamiento no ocurre

Generando reglas

Hay varias reglas que entran en juego para una ubicación de generación específica cuando un jugador reaparece:

  • Cuando SpawnLocation.Neutral está configurado como falso solo Players con Player.TeamColor que coincida con 1> Class.SpawnLocation.TeamColor1> respawnará por encima de él
  • Cuando SpawnLocation.Neutral está configurado como verdadero, cualquier jugador puede generar por encima de él independientemente de SpawnLocation.TeamColor
  • Si hay múltiples invocaciones elegibles disponibles para un Player, se elegirá una aleatoria
  • Los jugadores aparecerán en diferentes puntos en la parte superior de una SpawnLocation, pero actualmente, todavía pueden aparecer uno encima del otro si aparecen justo después de uno y otro

Véase también:

  • Si desea configurar el tiempo que tarda en reaparecer un jugador, consulte la propiedad RespawnTime

Amostras de código

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)

Resumo

Propriedades

  • Permite a un Player unirse al equipo tocando el SpawnLocation. Cuando se establece en verdadero, si un Player personaje viene en contacto con el 1> Class.SpawnLocation1>, el color del equipo del jugador se establecerá en 4> Class.

  • Ler Parallel

    La duración de tiempo, en segundos, que se aplicará a un personaje ForceField que se genera en este Player . Si la duración es cero, la SpawnLocation nunca se creará y no desencadenará los eventos 1> Class.

  • Ler Parallel

    Establece si el SpawnLocation está habilitado o no. Cuando los jugadores deshabilitados no pueden generar en el SpawnLocation y la función Permitir cambio de equipo en toque está deshabilitada.

  • Ler Parallel

    Si un SpawnLocation está afiliado con un equipo específico. Esto significa que cualquier Player , de cualquier Team, puede generar en él si esta propiedad está configurada como verdadera.

  • Ler Parallel

    Establece a qué equipo pertenece el SpawnLocation . Si la propiedad SpawnLocation.Neutral es falsa, solo Players con el mismo 2> Class.Player.TeamColor2> que el color del equipo del regeneraciónpodrá generar allí.

Propriedades herdados de PartPropriedades herdados de BasePartPropriedades herdados de PVInstance

Métodos

Métodos herdados de BasePartMétodos herdados de PVInstance

Eventos

Eventos herdados de BasePart

Propriedades

AllowTeamChangeOnTouch

Ler Parallel

Permite a un Player unirse al jugadoral tocar el SpawnLocation. Cuando se establece en verdadero

Esto no funcionará cuando SpawnLocation.Enabled esté configurado como falso.

Haciendo Puntos de Control

Esta característica a menudo se usa para crear puntos de control en carreras de obstáculos o similares.

Amostras de código

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

Ler Parallel

La duración de tiempo, en segundos, que se aplicará a un personaje ForceField que se genera en este Player . Si la duración es cero, la SpawnLocation nunca se creará y no desencadenará los eventos 1> Class.

Este valor predeterminado de esta propiedad es 10 segundos.

La función de duración permite a los desarrolladores brindar fácilmente protección a Players de 'spawn killing' que puede ser una experiencia frustrante para los jugadores. Nota, ForceFields sólo protegerá a los usuarios de Class.Explosion|

Amostras de código

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

Ler Parallel

Establece si el SpawnLocation está habilitado o no. Cuando los jugadores deshabilitados no pueden generar en el SpawnLocation y la función SpawnLocation.AllowTeamChangeOnTouch está deshabilitada.

Esta propiedad proporciona la forma más conveniente de evitar que Players aparezca en un regeneración.

Nota, aunque el cambio de equipo en el toque con el SpawnLocation.AllowTeamChangeOnTouch está desactivado cuando Enabled está configurado como falso, otros eventos tocados con el BasePart.Touched todavía se desencadenar.

Amostras de código

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

Ler Parallel

Si un spawn está afiliado con un equipo específico. Esto significa que cualquier Player , de cualquier Team , puede generar en él si esta propiedad está configurada como verdadera.

Si Neutral está establecido en falso, solo los jugadores cuyo Player.TeamColor es igual a SpawnLocation.TeamColor pueden usar el SpawnLocation.

Si SpawnLocation.AllowTeamChangeOnTouch es cierto, Player.Neutral será establecido a esta propiedad al contactar con el regeneración.

Amostras de código

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

Ler Parallel

La propiedad TeamColor establece qué equipo el SpawnLocation está afiliado. Si la propiedad SpawnLocation.Neutral es falsa, solo Players con el mismo 2> Class.Player.TeamColor2> que el color del equipo podrá generar allí.

Si SpawnLocation.AllowTeamChangeOnTouch es cierto, Player.Neutral será establecido a esta propiedad al contactar con el regeneración.

Amostras de código

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)

Métodos

Eventos