OnPlayerRequestSpawn
The client’s level is ready - decide where the player spawns, or hold them.
Set the spawn point with SetSpawnInfo and return true (or nothing): the player is spawned there - or at the server’s
default point without one - and OnPlayerSpawn follows. Return false to hold the player: their screen says
“waiting for the spawn” until the mode calls SpawnPlayer - a lobby, a team pick, a class menu. Called once per level
load, not on respawns.
Syntax
Section titled “Syntax”function OnPlayerRequestSpawn(pid) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the player |
Returns
Section titled “Returns”true or nothing spawns the player now; false holds them until SpawnPlayer
Example
Section titled “Example”function OnPlayerRequestSpawn(pid) local saved = GetSavedPlayer(pid) if saved and saved.x then SetSpawnInfo(pid, saved.x, saved.y, saved.z, saved.yaw) -- back where they left else SetSpawnInfo(pid, spawnX + 1.5 * (pid % 16), spawnY, spawnZ, spawnYaw) end return trueendSee also
Section titled “See also”SetSpawnInfo · SpawnPlayer · OnPlayerSpawn · the Players group of the index
