You may also want to consider changing the strings "On" and "Off" to the boolean values true and false. It won't generally make a huge difference (except for slightly simplifying certain constructs and, I suppose (?), a tiny advantage in processing time), but it just seems like good practice to me to use all data types exactly for what they were meant for. Two-state variables of the type on/off, yes/no, correct/incorrect, existent/non-existent and so on, are all archetypical examples of boolean toggles, so I'd generally use true/false for those.
(I know other people have other preferences there though and like using strings or numbers for some of those.)
Written with booleans, your function would become:
function lootSwitch()
if loot then
loot = false
else
loot = true
end
end
You see that using booleans will also shorten/simplify the if statement slightly. It also has the advantage that it lessens the risk of errors due to typos: If, in your original script you accidentally used "on" instead of "On" somewhere, it would produce unexpected results, since Lua is case-sensitive.