Code not working? Shows no script errors.

Hello, before you read the post note that I am very new to lua. This script was made for my deathrun server using Mr.Gash’s deathrun gamemode.

Okay so I wanted to create a system to where when a player is either a runner or a death a simple hud shows up displaying the controls and when they a spectating the hud is not displayed. Here is the code:


function deathCheck( ply )
	if ply:Team() == TEAM_SPECTATOR then
		return false
	end
	if ply:Team() == TEAM_RUNNER then
		hook.Add( "HUDPaint", "SpawnBox", function()
			draw.RoundedBox( 4, ScrW() * 0.40, ScrH() * 0.003, 255, 20, Color( 82, 111, 196, 200 ) )
		end )
		hook.Add( "HUDPaint", "SpawnText", function()
			draw.SimpleText( "F1: Tutorial | F3: Open Shop | F4: Thirdperson", Trebuchet24, ScrW() * 0.5, ScrH() * 0.005, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER )
		end )
	end
	if ply:Team() == TEAM_DEATH then
		hook.Add( "HUDPaint", "SpawnBox", function()
			draw.RoundedBox( 4, ScrW() * 0.40, ScrH() * 0.003, 255, 20, Color( 82, 111, 196, 200 ) )
		end )
		hook.Add( "HUDPaint", "SpawnText", function()
			draw.SimpleText( "F1: Tutorial | F3: Open Shop | F4: Thirdperson", Trebuchet24, ScrW() * 0.5, ScrH() * 0.005, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER )
		end )
	end
end
hook.Add( "PlayerSpawn", "DeathCheck", deathCheck )

So I tested it and I get no script errors but it isn’t working. Any help would be appreciated!

  1. PlayerSpawn is a SERVERSIDE hook.
  2. You are trying to draw things from a non drawing hook. That won’t work.

What would be a good hook to use for this occasion?

For drawing? HUDPaint.

I found the correct hook to use but the script doesnt even work. But thanks for the help anyways guys, ill fix the script myself.