Play Noclip/Specate Mode Issue

[lua]function Cleanup()
local Map = game.GetMap()
local MainMap = Map == “mg_piratewars_final_remake” or Map == “mg_xmas_piratewars_fix” or Map == “mg_balance_beta3” or Map == “mg_runbitch_run_v6_fix2” or Map == “mg_parcours_combattant_v1_fix” or Map == “fy_weaver-smash” or Map == “mg_hellz_multigame_fix_b7” or Map == “mg_ratrace” or Map == “mg_humantetrix_final” or Map == “mg_db_tanks” or Map == “mg_rolling_balls” or Map == “mg_boulderdash_race” or Map == “mg_hold_your_balance” or Map == “mg_rundoodrun1”
local SecondMap = Map == “mg_hilldash_beta2_fix” or Map == “mg_smashfloor_fix” or Map == “buses_from_hell_fixed” or Map == “mg_smash_cannonsz” or Map == “mg_monstertruck_arena” or Map == “mg_cave_escape_v2”

timer.Destroy("cleantimer")
game.CleanUpMap()

local Change = math.random(0, 1)

for k, v in pairs(player.GetAll()) do
	v:ChatPrint("[MG] Round restarted.")
	k = k + Change
	local Team = ( k % 2 ) + 2
	if MainMap then
		v:SetTeam( Team )
	else
		v:SetTeam(2)
	end
	v:StripWeapons()
	v:Spectate(OBS_MODE_NONE)
	v:Spawn()
	v:UnSpectate()
	v:SetMoveType(MOVETYPE_WALK)
	timer.Simple(.1, CheckNoclip, v)
	saveStat(v)
end

end

function CheckNoclip(pl)
if pl:GetMoveType()==MOVETYPE_FLY or pl:GetMoveType()==MOVETYPE_NOCLIP or pl:GetMoveType()==MOVETYPE_OBSERVER or pl:GetMoveType()==MOVETYPE_FLYGRAVITY or pl:Alive()==false or pl:GetObserverMode()!=OBS_MODE_NONE then
pl:Spectate(OBS_MODE_NONE)
pl:Spawn()
pl:UnSpectate()
pl:SetMoveType(MOVETYPE_WALK)
timer.Simple(.1, CheckNoclip, pl)
end
end[/lua]

That’s all the relevant lua.
Basically what happens is players will randomly spawn in some sort of half-noclip mode, where they still have weapons, but they are still pretty much in noclip mode.
It’s a big problem because they can kill the other team, and can’t be killed, but a simple spawn seems to do the trick to get them out of it.
The thing is, I have no clue how to automatically stop them from doing this. I’ve tried everything, the spawning part used to simply pl:Spawn() them, but I added all that extra crap to try to combat this “noclip” issue. I’ve even printed off the spectate mode that they were in during that noclip phase, and it seems to be MOVETYPE_FLYGRAVITY, but that anti-noclip check thing doesn’t seem to do anything about it.

Oops, I mean “Player” in the title… Oh well.

**[Player.StripWeapons

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.StripWeapons)** when it sets them to noclip mode.

No, the problem is that instead of spawning properly, they are put into a semi-spectator/noclip mode.

In my gamemodes, atleast, the ones with spectate, i only use.

**[Player.Spectate

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.Spectate)**(OBS_MODE_ROAMING)
and
**[Player.UnSpectate

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.UnSpectate)**

I dont think you have to change the movetype, simply the spectate function.

Yeah I used to do that, but like I said, no matter what combination of the above methods I used, they would still sometimes end up in that strange mode.

I have a feeling it’s a rare bug because this happens to players on my sever sometimes…

It happens quite often for me, it’s pretty annoying.