Sorry if it's a dumb question, but i'm still pretty new to the whole coding thing, and I thought I would get some more experienced opinions. I'm looking to have this script regenerate an npc if a certain amount of time passes, and the npc has full health.
The NPC is respawning, regardless of how much health he has, including full health.
I might just be a bingus, but thank you for taking the time to help me out!
object = script.Parent
if (object ~= nil) and (object ~= game.Workspace)and script.Parent.Humanoid.Health >= script.Parent.Humanoid.MaxHealth then
model = object
else
end
backup = model:clone()
waitTime = math.random(3,15)
wait(math.random(0, waitTime))
while true do
wait(waitTime)
model:remove()
model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
end

7 comments
Any errors?
No, there's no errors in the log at all.
what is line 2 all about?
Lines 7 and 8 are supposed to be inside the if statement.
And there's nothing in else block either.
I think Humanoid.Health cannot be grater than Humanoid.MaxHealth.
And if Humanoid.Health is smaller than Humanoid.MaxHealth model:clone() will error because model is nil.