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

I made a boss battles if i = 2 but something is not quite right?

if i == 2 then
			game.Lighting.DarkSkies.Parent = game.ServerStorage
			game.ServerStorage.Hell.Parent = game.Lighting
			game.Workspace.wave45:Stop()
			game.Workspace.FinalBossMusic:Play()
			game.ServerStorage.FinalBoss.Parent = game.Workspace
			game.ServerStorage.Towers.Parent = game.Workspace
			if 49999 > game.Workspace.FinalBoss.Humanoid.Health then
				game.Lighting.Hell.Parent = game.ServerStorage
				game.Workspace.FinalBossMusic:Stop()
				game.Workspace.FinalBoss.Parent = game.ServerStorage
				game.Workspace.Towers.Parent = game.ServerStorage
			end
		end
		

This is the code^ everything works fine until;

 if 49999 > game.Workspace.FinalBoss.Humanoid.Health then 

Boss normaly has 50k health and i want to make disappear everything when I shoot him once but it doesnt work everytime i try.

And I also tried;

if game.Workspace.FinalBoss.Humanoid.Health < 49999 then

But still not happend.

I will be very happy if this issiue solved :)

2 comments

1

That is because the if-statement was already evaluated; it was checked on runtime and proved false, thus reaching the EOF and the ultimate end of the program. You need to listen for an adjust in the boss' health and check then.

0

To reiterate what Ziff said, the if statement does not work because the script only checks it once when i = 2. You need to separate the two statements.

1 answer

✓ Accepted answer

You need to separate the two if statements by putting an

 end 

after the

 game.ServerStorage.Towers.Parent = game.Workspace 

and deleting the last

 end 

of the code. Your code should look like this:

 if i == 2 then
     game.Lighting.DarkSkies.Parent = game.ServerStorage
     game.ServerStorage.Hell.Parent = game.Lighting
     game.Workspace.wave45:Stop()
     game.Workspace.FinalBossMusic:Play()
     game.ServerStorage.FinalBoss.Parent = game.Workspace
     game.ServerStorage.Towers.Parent = game.Workspace
     end
     if 49999 > game.Workspace.FinalBoss.Humanoid.Health then
	     game.Lighting.Hell.Parent = game.ServerStorage
	     game.Workspace.FinalBossMusic:Stop()
	     game.Workspace.FinalBoss.Parent = game.ServerStorage
	     game.Workspace.Towers.Parent = game.ServerStorage
     end

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