I made a respawn script for a mob that I made but everytime I set the health back to 100 it just keeps 0... why is that? Here is the script
name="Humanoid"
local maxhealth = 100
local load = script.Parent.Humanoid:LoadAnimation(script.Parent.Idle)
load:Play()
script.Parent.Humanoid.Changed:Connect(function()
if script.Parent.Humanoid.Health < 1 and script.Parent.Dead.Value == false then
script.Parent.Dead.Value = true
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("MeshPart") then
for i = 1,10 do
wait(.05)
v.Transparency = v.Transparency + 0.1
end
end
end
print("Bot died")
wait(5)
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("MeshPart") then
v.Transparency = 0
end
end
script.Parent.Humanoid.Health = maxhealth -- Over here I set it back
wait(1)
script.Parent.Dead.Value = false
end
end)

1 comment
This should Help you https://scriptinghelpers.org/questions/90165/how-can-i-make-a-bots-respawnfight