title: How to break out of a loop in x seconds
body: <p>I am trying to modify a FiveM script and I am trying to break out of a loop in Lua after 4 seconds but I don't know how.</p>
  
  <p>I don't know what I am doing and need some help.</p>
  
  <pre class="lang-lua prettyprint-override"><code>Citizen.CreateThread(function()
      function drawscaleform(scaleform)
          scaleform = RequestScaleformMovie(scaleform)
  
          while not HasScaleformMovieLoaded(scaleform) do
              Citizen.Wait(0)
          end
  
          PushScaleformMovieFunction(scaleform, "SHOW_POPUP_WARNING")
          PushScaleformMovieFunctionParameterFloat(500.0)
          PushScaleformMovieFunctionParameterString("ALERT")
          PushScaleformMovieFunctionParameterString("~b~Peacetime Active")
          PushScaleformMovieFunctionParameterString("This Means No Priority Calls")
          PushScaleformMovieFunctionParameterBool(true)
          PushScaleformMovieFunctionParameterInt(0)
          PopScaleformMovieFunctionVoid()
  
          DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
      end
  
      while true do
          Citizen.Wait(0)
          drawscaleform("POPUP_WARNING")
      end
  end)
  </code></pre>
  
  <p>I would like to break out of the <code>while true</code> after 4 seconds</p>