Insert an if query into the script to check if a condition or Lua variable is true or false.
It's shown/explained
here in the tutorial I wrote ages back. Back then videos still got skipped with ESC, but I don't know if that's the case anymore as I haven't tried testing it since.