Some troubles with Gmod

hey guys, ive been making a gamemode and ive been having some trouble with a couple of things.

First, my gamemode has rounds so i want to keep the player dead until the next round start and i don’t know how to do that, i have been trying with ply:Spectate() but is not working.

Second this script should prevent new players from spawning but isnt working


function GM:PlayerInitialSpawn( ply )
 
    ply:SetTeam( TEAM_SPEC ) --Add the player to team Spectators
	ply:KillSilent()
	ply:Spectate( OBS_MODE_ROAMING )
	MsgN( "HM:" .. ply:Nick() .. " connected" )
end

i`ll appreciate any help

HOAX

PS: Im reposting from http://forum.facepunch.com/showthread.php?t=1201863&p=37010563#post37010563 because i dont know how to move it or delete the old one

What is the error that the return alive is causing?

gmod doesnt run the lua file (init.lua) i know that its the error because i make that a comment and the mod works correctly

Have you made sure you setup the spectator team correctly?

Does TEAM_SPEC actually point towards an existing global integer which represents the team number.

It would be immensely helpful if you could actually copy the error and paste it here.

you have to post what the error says if you want people to try to help.

Ok, forget that code you have there, and instead use this at the init.lua.

[lua]
function GM:PlayerDeathThink( ply )
return false
end
[/lua]

It stops players from spawning, so if you want players to spawn, e.g: At the start of a round, you need to force spawn them using lua, like:

[lua]

for _, v in pairs(player.GetAll()) do
v:Spawn()
end

[/lua]

thank you guys but i already solved it, i found out how to correctly use player.Spectate().