Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Humanoid respawn with more health?

hello, im pretty new to building, but im trying to make this game. i want to make a NPC or Zombies respawn with more health. for example, it'll have a MaxHealth of 100, and then on its cloning function come back with a MaxHealth of 200. I've tried this:

name="Humanoid"

robo=script.Parent:clone()

while true do
	wait(1)
	if script.Parent.Humanoid.Health<1 then
		robot.humanoid.maxhealth = robot.humanoid.maxhealth + 100
		robot.humanoid.maxhealth = robot.humanoid.health + 100
		robot=robo:clone()
		robot.Parent=script.Parent.Parent
		robot:makeJoints()
		script.Parent:remove()
	end
end

but it doesnt seem to work. any ideas on what i can do?

2 answers

✓ Accepted answer

Try this:

name="Humanoid"

robo=script.Parent:clone()

script.Parent.Humanoid.Died:connect(function()
--Your code
end)

4 comments

0

ok cool! i got it to work. what u said gave me this idea:

0
0

It would be nice if you accept this answer :D

0

I'd be more than happy to. how do i do that? this is legit my first time on this website LOL

heres the answer/code if anyone else wants it(edit, this one worked a bit better)

local myHuman = script.Parent:WaitForChild("Humanoid")
local clone = script.Parent:Clone()

function died()
	clone.Humanoid.MaxHealth = clone.Humanoid.MaxHealth +100
	clone.Humanoid.Health = clone.Humanoid.Health +100
	wait(5)
	clone.Parent = workspace
	clone.Humanoid.MaxHealth = clone.Humanoid.MaxHealth +100
	clone.Humanoid.Health = clone.Humanoid.Health +100
	game:GetService("Debris"):AddItem(script.Parent,0.1)--this probably isnt needed but i have it in my scripting
end

myHuman.Died:Connect(died) --

1 comment

0

*Humanoid.Died

This discussion is preserved as it was. New answers, comments, and votes are closed.