Help - If statement only triggering once and not repeating again even if condition is met

Im trying to trigger the notif and sound once to alert the player then stop the loop (if the condition is met).
I want it to always be reading for the condtion!

Example:
player is low fuel (show notif and play sound once)
player fills up fuel
when player is low on fuel again (show notif and play sound once)

Actual outcome of this code:
player is low fuel (show notif and play sound once)
player fills up fuel
player is low on fuel (does nothing as wont trigger again)
WHEN PLAYER GETS LOW ON FUEL AGAIN IT WONT TRIGGER IT EVER AGAIN AFTER THE FIRST TRIGGER

This has been killing me please help :slight_smile:

Hey there,

From my understanding if I want to break out of loop I need “break”. I think so. Yeah, you need break in your while true do loop on line 66. Otherwise it will be just repeating itself no matter if its inside or outside of repeat until.

1 Like

You can delete the last loop to set the fuelLow = true and place it inside your if statement.
Something like this:

while true do
     if IsPedInAnyVehicle(player, vehicle, true) then
          if fuel <= 15 then -- fuel is low
              fuelLow = true -- set fuel is low
          else -- so the fuel is not low
              fuelLow = false
          end
              repeat -- do your loop while it's low
              until fuelLow == true
     end
end