Regenerating Health using GM:PlayerHurt?

I’m trying to create a regenerating for my gamemode but I can’t wrap my head around how to accomplish this task. Below you can find my current code, I’m not able to test it atm so I’m not sure what it will do. I’m trying to make it so that, depending on the players damage taken they’ll have different “blood loss” rates otherwise just regenerate their health. Also, should I be using

GM:PlayerHurt for this?



function GM:PlayerHurt(victim, attacker, remainingh, takenh)
	local function ply:Healing()
		local curh = self:Health()
		self:SetNWBool("Healing", true) --Used for healing HUD symbol
		while curh < self:GetMaxHealth() then
			if curh == self:GetMaxHealth() then
				self:SetNWBool("Healing", false) --Used for healing HUD symbol
			else
				timer.Simple( 20, function() self:SetHealth( curh + 10 ) end )
			end
		end
	end

	local function ply:Bleeding(type)
		local curh = self:Health()
		if type = "minor" then
			while curh < self:GetMaxHealth() then
				timer.Simple( 30, function() self:SetHealth( curh - 3 ) end )
			end
		else if type = "major" then
			while curh < self:GetMaxHealth() then
				timer.Simple( 25, function() self:SetHealth( curh - 6 ) end )
			end
		end
	end

	if victim:IsPlayer() && attacker:IsValid() then
		if takenh >= 80 then
			victim:Bleeding(major)
		else if takenh >= 60 then
			victim:Bleeding(minor)
		else
			victim:Healing()
		end
	end
end


I’m currently working on my gamemode so Ill just slap this in it and test it for you

Well, you have 2 extra ends on your code, but it breaks everything and I can’t find there error

You are defining local functions every time the PlayerHurt function is run.
The functions you are defining are meta functions, and therefore cannot be local functions.
‘ply’ does not exist.
You have overridden the default PlayerHurt function. Use hook.Add
You are using ‘while’ loops and are crashing the game.

Why are you disagreeing him, he’s right in every point, he’s creating a gamemode, so there’s not harm in using GM:PlayerHurt
[sp]and before you start with huuuh who cares about ratings, you might confuse op by telling he’s wrong[/sp]

-snip-

that part I didn’t see, oops