Player healed when kill script doesnt work

function op(pl) 
function oc(char) 
local h = char.Humanoid 
function od() 
local c = h:findFirstChild("creator") 
if c ~= nil then 
local k = c.Value 
if k ~= nil then 
wait(1)
k.Character.Humanoid.Health = k.Character.Humanoid.MaxHealth
end 
end 
end 
h.Died:connect(od) 
end 
pl.CharacterAdded:connect(oc) 
end 
game.Players.PlayerAdded:connect(op) 

This script doesnt work when I kill a player. I have put the script in scriptstorage, can somebdoy help me?

1 Like

When a humanoid reaches 0 hp they are probably dead so you can’t heal them back
An alternative way would be to insert a numbervalue inside the character and make it represent the humanoid’s hp. If you want the default healthbar to still appear above the character you could make it so that the value syncs up with the health of the humanoid but doesn’t go below 0.

1 Like

Are there any errors in output? Please if possible try to format your code by indentation.

Also, findFirstChild is deprecated, try using FindFirstChild.

@Physicionics I believe k references the creator Value, aka the person who killed the player.

1 Like

What I mean is basically when a player kills a player, the player who killed the player gets their health filled to the max.

1 Like

FindFirstChild doesnt work. I’ve tried that just right now.

^^ Could you provide us with this information?

One thing I noticed, I see that you have done:

local h = char.Humanoid

Try using WaitForChild as the Humanoid may not have already loaded in yet on CharacterAdded.

o ok
Why don’t you use weapon’s kill script. If it’s a local script you can use a remote event to tell the server they killed somebody or something and then heal them.

This is what I want it to do.

adding onto what @AbiZinho said, try putting print() statements after each function and if lines so that it’s easier to troubleshoot