Lua Switch Statements? How does it work?

Hello!

I basically made a script that had a lot of checks, and was introduced to “Switch Statements” by a friend.

How would I use a switch statement in this situation? (Not even sure if Lua Switch Statements Exist)

local dayTime = (11);

if dayTime == (11) then
   print("It's morning.")
elseif dayTime == (18) then
   print("It's afternoon.")
end

They don’t actually have switch statements, but there’s a few ways of mimicking them: lua-users wiki: Switch Statement

3 Likes

I recommend this resource due to Lua not having a native implementation:

7 Likes