Lua logic test

I’m gonna keep this simple.
I’m learning lua and I wanted to try something to see if my logic was solid, it wasn’t. What I wrote was this: http://pastebin.com/c84iaFqQ
Basically, when the player spawns they’re set to TEAM_SPECTATOR and set to OBS_MODE_ROAMING, and I wanted it so that the player, when the Suit Zoom key is pressed, to spawn in either TEAM_DEATH or TEAM_RUNNER.
I would like some help as to why this isn’t working, mostly to understand why it isn’t, and less of the fact that it’s an important addition to the gamemode.
Thanks.

math.random does not choose between two options. It returns a random number between the first and the second.

[lua]math.random(1, 100)[/lua]

would return a random number between 1 to 100.

Use something along the lines of this:



local t = (math.random(1, 2) == 1) and option_one or option_two