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:Spectate( OBS_MODE_ROAMING )
	MsgN( "HM:" .. ply:Nick() .. " connected" )

i`ll appreciate any help


PS: Im reposting from 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.

function GM:PlayerDeathThink( ply )
return false

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:


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


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