Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script is just ignoring a conditional statement?

Asked by 6 years ago

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
0
Any errors? nicktooner 119 — 6y
0
No, there's no errors in the log at all. hulabee 7 — 6y
0
what is line 2 all about? greatneil80 2647 — 6y
0
Lines 7 and 8 are supposed to be inside the if statement. LinKiNSpitZ 22 — 6y
View all comments (3 more)
0
And there's nothing in else block either. LinKiNSpitZ 22 — 6y
0
I think Humanoid.Health cannot be grater than Humanoid.MaxHealth. LinKiNSpitZ 22 — 6y
0
And if Humanoid.Health is smaller than Humanoid.MaxHealth model:clone() will error because model is nil. LinKiNSpitZ 22 — 6y

Answer this question