Spectate problem

I have a problem to set player to spectate mode after joining.

I get no errors but he is not in spactating mode.

function GM:PlayerInitialSpawn( ply )
    joining( ply )
    ply:SendLua( "welocomescr()" ) //Show welcome screen


function joining( ply ) 

    ply:Spectate( OBS_MODE_ROAMING )
    ply:SetTeam( 3 ) //Set his team to Joining

But when i do this it works:

function spectate( ply )
    ply:Spectate( OBS_MODE_ROAMING )

concommand.Add( "spectate", spectate )

– Snip – Didnt read at all…

He is calling it…

Try putting “joining( ply )” after a 5-10 second simple.timer as it might be happening before the player is actually spawned.

Ok I replaced it with:
timer.Simple( 1, joining, ply )

and it is working now THX