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

This if statement won't run?

So, I've made a script that checks an AI's health, and if the AI's health is below 700, it's supposed to switch his swords

I've ran the code in the command bar and it worked fine, but whenever I add it into a script, it doesn't execute the if statement (or at least that's what I'm guessing, because once I damage the AI past 700, it doesn't switch swords

It's in a script located inside Workspace

	if game.Workspace.AI.Sword.Humanoid.Health <= 700 then
		game.Workspace.AI.Sword.FireSword:Remove()
		game.Lighting.SecondSword:Clone().Parent = game.Workspace.AI.Sword
	end

3 comments

1

Can I see the rest of the code please?

0

Make sure the script isn't disabled.

0

That's all of it @legokendall

1 answer

✓ Accepted answer

Add a while wait() do.

while wait() do
	if game.Workspace.AI.Sword.Humanoid.Health <= 700 then
    		game.Workspace.AI.Sword.FireSword:Remove()
    		game.Lighting.SecondSword:Clone().Parent = game.Workspace.AI.Sword
	end
end

if this worked your welcome :) ~KIheros

2 comments

0

Thank you!

0

You are welcome! :)

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