Comparing players health to their max?

I cant seem to find the code to see if the players health is less then their max

i’ve tried many things but none seem to work i’ve tried


function ITEM:OnHolster(ply)
local hp = ply:Health()
local maxhp = ply:GetMaxHealth()
if hp < maxhp then
return false
else
	ply:SetHealth(100)
	ply:SetMaxHealth(100)
	end
end

and many other things but they dont seem to work

What i want is that if the player has less than their max health then dont holster the powerup and print a message like “You may only holster if your on full health” or something

No one knows how to do this??

should work ur doing something wrong idk

try this at the top

[lua]
if ( not ply or not ply:IsPlayer() ) then
print(“i didn’t code my weapon base right”);
return;
end
[/lua]

in other words is your player object valid
is this called on the server only?
is the function( OnHolster ) even being called? add a print to the top to see when it’s called.
does the weapon work when you remove this function from the swep file?

Its for a pointshop powerup

What exactly is the issue your getting? It is saying if your hp is less than max you can’t holster it, else, it sets your hp to 100.

well you didn’t answer any of the questions i needed in order to debug your script so i guess i’m not helping you