Spectator mode not working

Just encountered the same problem I had ~6 months ago. If I try to let players spectate, they bounce quickly up and down of the floor, while I’m trying to achieve roaming mode.

local function SpecMode( bool )
	for k,Player in pairs( player.GetAll() ) do
		if bool then
			Player:StripAmmo( )
			Player:StripWeapons( );
			Player:Spectate( OBS_MODE_ROAMING )

Any clue on how to fix this?

This works perfectly fine for me, maybe you have something conflicting with it.

Got no addons apart from cs materials.

Potentional useful info: Its on a custom gamemode inherited from base, but it barely got any code

Well im on a clean sandbox server that i use to test my stuff and the code works perfectly fine. What gamemode are you using? Does it have its own spectate feature that could interfering?

It barely got any code as I said, its in the only file after init & cl_init (serverside)

Oh and even if I derive from Sandbox, it still doesn’t work

I mean I’m on sandbox right now, nothing special about the server and i copied the code you had and put it into my a in game lua editor and ran it just fine, it put me in and out of spectator mode like it should and i could free roam

It works for me on Sandbox too, so I’m kinda clueless on why it doesn’t work in a custom gamemode