Script that heals a humanoid to full health when it "dies"

the title explains it, I’ve tried using the Died function and checking if the humanoid’s health went to 0, none worked

if script.Parent.Humanoid.Health == 0 then
	script.Parent.Humanoid.Health = script.Parent.Humanoid.MaxHealth
end

fyi, loops dont work either :frowning:

1 Like

Your trying to make a player get max health when he kills another player, or an npc that when it kills the player gets maxhp?

no, im trying to make a test dummy that instantly heals as soon as it ‘dies’, and I dont want to use respawning. I’ve seen what im describing in a different game.

I think the only way is to respawn the dummy as fast as possible, you cant set the dummy to maxhp when the humanoid already died so do a script with a respawn delay of 0.1

how would i respawn it where it died?

If you group the dummy in a model and inside that model you put this script it should respawn it instantly.

local Model = script.Parent
local CurrentFigure = Model.Dummy

local Figure = CurrentFigure:Clone()
local RESPAWN_DELAY = 0.001
local CanSpawn = true

function Respawn()
	wait(RESPAWN_DELAY)
	
	CurrentFigure:Destroy()
	CurrentFigure = Figure:Clone()
	CurrentFigure:MakeJoints()
	CurrentFigure.Parent = Model
	CurrentFigure.Humanoid.Died:connect(onDied)

end
function onRemoved(Object)
	if Object == CurrentFigure and CanSpawn then
		Respawn()
	end

end
function onDied()
	if CanSpawn then
		CanSpawn = false
		Respawn()
		CanSpawn = true
	end
end

CurrentFigure.Humanoid.Died:connect(onDied)
Model.ChildRemoved:connect(onRemoved)

does it have to be a model? or can it be a folder

Yeah but change model and currentfigure variable

i thought its not possible but changing the hum state and setting BreakJointsOnDeath to false works to me

local Humanoid = script.Parent.Humanoid

Humanoid.BreakJointsOnDeath = false

Humanoid.Died:Connect(function()
	Humanoid:ChangeState(Enum.HumanoidStateType.Running)
	Humanoid.Health = Humanoid.MaxHealth
end)
1 Like

Also needs to be a server script