Garry's Mod Wiki


GM:PlayerInitialSpawn( Player player, boolean transition )


Called when the player spawns for the first time.

See GM:PlayerSpawn for a hook called every player spawn.

This hook is called before the player has fully loaded, when the player is still in seeing the "Starting Lua" screen. For example, trying to use the Entity:GetModel function will return the default model ("player/default.mdl")
Due to the above note, sending net messages to the spawned player in this hook is highly unreliable, and they most likely won't be received. See A quick and dirty work-around is to delay any sending using timer.Simple with at least 5 seconds delay.


1 Player player
The player who spawned.
2 boolean transition
If true, the player just spawned from a map transition.


Prints the name of the player joining.

function GM:PlayerInitialSpawn(ply) print( ply:GetName().." joined the server.\n" ) end -- That way you are overriding the default hook -- you can use hook.Add to make more functions get called when this event occurs local function spawn(ply) print( ply:GetName().." joined the game.\n") end hook.Add( "PlayerInitialSpawn", "some_unique_name", spawn )
Output: Player1 joined the game

Page Links

Special Pages



Render Time: 33ms

Session 0
DB GetPage 5
Generate Html 6
SaveChanges 14
Render Body 0
Render Sidebar 6