I want to get either a random true or false value, but mine seems really inefficient and I'm sure there are a few much more efficient ways of doing exactly what mine does. Here's my code:
1 | local variable |
2 | if math.random( 1 , 2 ) = = 1 then |
3 | variable = true |
4 | else |
5 | variable = false |
6 | end |
My way might be the most efficient way but I don't think it is, that code is just a general way of showing what my script does, it's not the full script.
The best way to do this can be done on 1 line, simply have the variable assigned to a condition. Here's the most efficient way:
1 | local variable = math.random( 1 , 2 ) = = 1 |
That will give you a random true or false value each time.