halo.Add not changing on ENT:Think() function.

Hello.

I’m trying to have my Entity glow different colors depending on it’s health. But It doesn’t seem to want to do that.

I start the Initialize function by adding this:
[lua]
self.hp = 500
self.MyColor = Color( 0, 255, 0, 255 )
[/lua]

Then the HP is handled by the OnTakeDamage function:
[lua]
function ENT:OnTakeDamage(dmg)

self.hp = self.hp - dmg:GetDamage()

if(self.hp <= 0) then 
	self:Remove(); 
end

end
[/lua]

Then the glow via the Think function:
[lua]
function ENT:Think()

if self.hp == 500 then
	self.MyHPColor = Color( 0, 255, 0, 255 )
else
	self.MyHPColor = Color( 255, 0, 0, 255 )
end

if ( CLIENT && LocalPlayer():EyePos():Distance( self:GetPos() ) < 130 ) then
	if ( LocalPlayer():GetEyeTrace().Entity != self ) then return false end
	AddWorldTip( self:EntIndex(), "Press E to shake.

Destroy for wood logs.", 1, self:GetPos(), self.Entity )
halo.Add( { self }, self.MyHPColor, 15, 15, 1, true, true )
end

end
[/lua]

However, the color doesn’t seem to change at all.
I tried this with no luck either:
[lua]
function ENT:Think()

if self.hp == 500 then
	self.MyHPRed = 0
	self.MyHPGreen = 255
	self.MyHPBlue = 0
else
	self.MyHPRed = 255
	self.MyHPGreen = 0
	self.MyHPBlue = 0
end

if ( CLIENT && LocalPlayer():EyePos():Distance( self:GetPos() ) < 130 ) then
	if ( LocalPlayer():GetEyeTrace().Entity != self ) then return false end
	AddWorldTip( self:EntIndex(), "Press E to shake.

Destroy for wood logs.", 1, self:GetPos(), self.Entity )
halo.Add( { self }, Color(self.MyHPRed,self.MyHPGreen,self.MyHPBlue,255), 15, 15, 1, true, true )
end

end
[/lua]

However. If I do this:

[lua]
function ENT:Think()

self.MyHPColor = Color(255,0,0,255)

if ( CLIENT && LocalPlayer():EyePos():Distance( self:GetPos() ) < 130 ) then
	if ( LocalPlayer():GetEyeTrace().Entity != self ) then return false end
	AddWorldTip( self:EntIndex(), "Press E to shake.

Destroy for wood logs.", 1, self:GetPos(), self.Entity )
halo.Add( { self }, Color(self.MyHPRed,self.MyHPColor,self.MyHPBlue,255), 15, 15, 1, true, true )
end

end
[/lua]

And I change it DIRECTLY on the think, the color changes!

So what’s the issue?

ENT:OnTakeDamage is only called serverside, so self.hp only changes on the server. Network it or just use http://wiki.garrysmod.com/page/Entity/SetHealth and http://wiki.garrysmod.com/page/Entity/Health.

Thank you. I swear, The differences of clientside and serverside variables are going to be the death of me. I REALLY need to get used to their differences.

However It still fails to work. Both Networked and by using Health.

-bump-

Tip: Health is not networked in singleplayer for SENTs.

Post new code.