Healing Players

So I found out that the wiki says that the player object has a lot of the functions an entity has, and the entity object has a TakeDamage function. I am trying to make a sortof “Magic Potion” that will heal players. Here is my code, placed into the Primary Attack function

// Called when the player Shoots
function SWEP:PrimaryAttack()
	if ( !self:CanPrimaryAttack() ) then return end
	if debug then
		print("Primary Attack")
		// Put Your debugging Code in here
	// Any Code you want to be executed when the player uses primary attack goes in here
	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
	if ( SERVER ) then
		self.Owner:TakeDamage(-20,self.Owner, self)
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Delay )
	self.Weapon:SetNextSecondaryFire( CurTime() + self.Delay )

So is this correct or no?

self.Owner:SetHealth( self.Owner:Health() + 20 )


Note: it can give the player over 100 health.

Well, if you want to heal the, you should probably use SetHealth instead of TakeDamage. TakeDamage should typically be called only for damage.

Ah, didn’t see that in the wiki. I did edit->find health too =/