I have a script with a repeat loop that uses if statements to cycle between the player's and enemy's turns. At the beginning of the if statement, it checks if the enemy health or player health is below 0 or equal to 0 to break. At which is makes the until statement true, so the repeat loop breaks and the player can continue. However, when I set the health values to 0 or below 0, the if statement doesn't fire and the loop between the player's turn and enemy's turn continues without stopping. The health values are actually intvalues and not humanoid properties. Here is a snippet of the script.
if fighting.Value == false then -- checks if they not in battle
debounce = false
fighting.Value = true -- puts player in battle
-- setting up player's stats and enemy's stats
PHealth.Value = PMaxHealth.Value
PAP.Value = PMaxAP.Value
PFocus.Value = PMaxFocus.Value
EHealth.Value = EMaxHealth.Value
EAP.Value = EMaxAP.Value
EFocus.Value = EMaxFocus.Value
hit.Parent.HumanoidRootPart.Position = script.Parent.Parent.PlayerStartPos.Position -- puts player onto arena
local playerturn = true
local enemyturn = false
repeat -- loops them in battle until they are not
if EHealth.Value <= 0 or PHealth.Value <= 0 then -- checks if someone in battle died
print("Battle end") -- battle end not firing
hit.Parent.HumanoidRootPart.Position = script.Parent.Parent.ExitPos.Position
fighting.Value = false
debounce = true
playerturn = false
enemyturn = false
break
elseif playerturn == true then
print("PTurn")
wait(1)
playerturn = false
enemyturn = true
elseif enemyturn == true then
print("ETurn")
wait(1)
enemyturn = false
playerturn = true
end
wait(0.01)
until fighting.Value == true -- (Continued) loop breaks at the end of they are done fighting
end
The snippet of this script is wrapped inside a touch event, and a bunch of locals are before this snippet. Those are the values of setting up the player's and enemy's stats. I have also tried using a while loop instead, which didn't work. Including breaks, deleting all or some breaks, and turning the playerturn and enemyturn if statements into a different if statement instead of using elseif to continue the if statemtent didn't work (I've tried on both loops). I've moved the if statement to below the playerturn and enemyturn if statments, still didn't work.
Here is the while loop:
while fighting.Value == true do -- loops them in battle until they are not
if EHealth.Value <= 0 or PHealth.Value <= 0 then -- checks if someone in battle died
print("Battle end") -- battle end not firing
hit.Parent.HumanoidRootPart.Position = script.Parent.Parent.ExitPos.Position
fighting.Value = false
debounce = true
playerturn = false
enemyturn = false
break
elseif playerturn == true then
print("PTurn")
wait(1)
playerturn = false
enemyturn = true
elseif enemyturn == true then
print("ETurn")
wait(1)
enemyturn = false
playerturn = true
end
wait(0.01)
end
Both loops end with PTurn and ETurn repeatedly printing after I set either or both health values to 0. I believe I'm having problems with the if statement detecting the health values being under or equal to 0. I do think one solution would be to rewrite the entire code differently and seeing if that works, but I'd like to check for any solutions to this script first.

2 comments
Did you change them while in client mode (i.e. https://i.imgur.com/Mvm602Q.png)?
Changing the health value to 0 in both client mode and server mode didn't work.