That's the whole question lol.
✓ ANSWER ACCEPTED
Can someone explain when and why you use ; this sometimes??
1 answer
✓ Accepted answer
Semicolons are usually optional and can be used to visually separate statements (ex on the same line). They are mandatory if you do something like this:
local myVar = 5
print("Hello")
(myVar == 5 and print or warn)("This line will error because there is no semicolon")
Specifically, it will error with ambiguous syntax (function call x new statement) near '('. Adding a semicolon after line 2 or at the start of line 3 fixes it:
local myVar = 5
print("Hello")
;(myVar == 5 and print or warn)("This message will be printed since myVar is 5")
Does this happen in practice? It can; though it's rare, sometimes it's nice to be able to specify which function you want to use (via the and or "ternary") in the same line you use it.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
so you can write multiple statements on the same line like
print(5);print(3)oh ,ok Thank You
we can use it to write multiple statements, but a lot of the time it's just habit. people write in other coding languages which can carry over to Lua, leading to people ending declarations with the semicolon (but not function calls).