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?
Try this:
name="Humanoid" robo=script.Parent:clone() script.Parent.Humanoid.Died:connect(function() --Your code end)
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) --