Player Health Issues

As you all know, I’m having issues with this HUD regarding it displaying health. Here is the script, could someone please tell me what the problem was? -_-

include( 'shared.lua' )

function hidehud(name)
	for k, v in pairs{"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"} do
		if name == v then return false end
hook.Add("HUDShouldDraw", "hidehud", hidehud)

plyHealth = player:Health()

function drawGMHUD()
	roundsChambered = Player:GetActiveWeapon():Clip1()
	bulletsRemaining = Player:GetAmmoCount(Player:GetActiveWeapon():GetPrimaryAmmoType())
	specialMunitions = Player:GetAmmoCount(Player:GetActiveWeapon():GetSecondaryAmmoType())
		draw.RoundedBox( 3, 100, 80, 200, 60, Color( 255, 0, 0, 255 ) )
		draw.SimpleText( roundsChambered, "ScoreboardText", 35, 60, Color(220,220,40,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
		draw.SimpleText( bulletsRemaining, "ScoreboardText", 55, 60, Color(220,220,40,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
		draw.SimpleText( plyHealth, "ScoreboardText", 75, 50, Color(255,0,0,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

hook.Add("HUDPaint", "hud", drawGMHUD)

A. This process goes 100x better if you tell us what the problem is, so we can tell you the solution.

B. Your health won’t update because you define it outside of the HUDPaint hook.

C. None of the info you get, ammo or player health, will work because you perform it on some ambiguous variable “Player” which you seemingly pick out of nowhere. Variables like that don’t just appear out of thin air, you have to get them from somewhere. In this case, to get the player running this script you want to use the global function **[G.LocalPlayer](**.

Er… I guess I shouldn’t have deviated from the tutorial that much then. But what the problem was with the whole health thing, and the precise error I got from console was; Civilization/gamemode/cl_init.lua:10: attempt to index global ‘ply’ (a nil value)

Ok, that’s again because you never defined “ply” or “player” or “Player”. See my response C again.