Question:
this is what i have right now and i have no clue how to even make random stuff (other than math.random, which doesn’t work) can someone help with this please? i’ve been trying different things for hours and can figure out how to do any randomize codesAnswer:
(to preface, i dont know anything about roblox specifically, just lua in general) math.random is the thing to use, but it requires some specific for your case.presuming that you need a 4-digit integer code,
math.random(1,9999)
should give that (http://lua-users.org/wiki/MathLibraryTutorial). Then, to compare it with the input (which i see is a string), you can either turn the input to a number (tonumber("1234"))
, or the actual code to a string (tostring(math.random(1,9999))
.Since lua does not care for floats/integers/etc, just numbers, I would go with the tonumber route, since you dodge string formatting that way.
To seed your randomiser, you can use math.randomseed(), for example with the system time (since the seed will be different every time, the code will be different every time). note that that sets the seed for any random call after that, not just that one call.
I hope this helped.
If you have better answer, please add a comment about this, thank you!