Help with knock-out system

As many games such as rogue lineage and mighty omega have done, instead of dying when the player’s health hits 0, they get knocked out and can then be executed. I’m trying to make this.

I’ve already seen many threads about knockout systems and such but all of them say to set humanoid state ‘dead’ to false.

While this does somewhat work, the player still respawns after a few seconds of being knocked out.

here’s my code:

--local script
local knocked = false
hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false)

hum.HealthChanged:Connect(function()
	if hum.Health <= 0 then
		if not knocked then
			knocked = true
			RS.Misc.Knocked:FireServer()
			kneel:Play() --animation
			kneeling:Play() --animation
		end
	end
end)

another solution i saw was to make a custom health system but i’ve seen games use roblox health and still accomplish the same thing so i was trying to be more optimized.

cant you make the players normal health 110 and make the health that makes you get knocked out 10?

but the player would still be able to die if something dealt more than 10 damage at once. even if i set the normal health 300 and the knockout health 200, it feels kind of hacky and i bet there would be bugs along with it.

Add a damaging function and each time check if they’re gonna die from the damage and knock them

– writing code rn

function module:Damage(Humanoid,Damage)
    if Humanoid.Health - Damage <= 0 then
           Humanoid.Health = 0.1 -- knock them and stuff
           else
           Humanoid:TakeDamage(Damage)
     end
end
2 Likes