I am making a Boss that will randomly choose an attack, basically, I want this loop to detect when the Alive value is no longer true and start the death function. However, with this script, when it has 0 health it waits until it finishes an attack before doing the death function which isn't how it is supposed to work. Basically, the instant the Alive Value is false, I want it to stop what it is doing and play its death animation, and I have no idea how to.
This is the main part of the script, the attacks are usually 5 to 10 seconds so its really awkward when the Boss is at 0 health and he hasn't died until after he finishes attacking.
while Alive.Value==true do wait(2.5) FireSequence()--A missile firing sequence that takes a couple seconds wait(2.5) RanChoice=math.random(1,5) if RanChoice==1 then print"FLAMETHROWER" Flame()--A flame throwing sequence that takes a couple seconds elseif RanChoice==2 then laser()--A laser shooting sequence that takes a couple seconds wait(1) Move()--Moves the boss else Move() end end print"DEAD" Death()--This is supposed to activate when Alive.Value==false
Yes, this script it fine it is because the Waits inside of the "While true do" part So basically It has to wait the 2.5 seconds to start the loop over and until it starts the loop over it wont see that the Alive Value is false do you read me?
Put your loop in a function, put the function inside a loop wich will check if the Alive value is true or not ( and don't forget the wait inside the main loop ).