You didnt do anything wrong, this is how computers work. Computers can’t be random, at least not digital ones (Quantum ones might). So a computer to be “random” it takes exterior factors, for example the weather, the runtime, the inputs, the day, the date etc… To generate the random number.
I’d recommend just decreasing the chances until it seems random enough
And @WallsAreForClimbing has said that wait() is to be deprecated soon, however I cannot find the original reply where he said that, so you’re just gonna have to take my word for it.
Could you please clarify what you mean by physics-based throttling?
As physics calculations noticeably drop, the update rate would also drop. This is useful for when you want to consider physical simulations, especially those rendered on the server - and not use exact real-life time. For example, you’d like to give the player 5 seconds to run to a safe platform from a sinking one. If physics updates were to suddenly slow down, the player would be given more time to react and move. Otherwise, it would be near impossible for the player to get to the safe platform.
Isn’t task.wait() more performant though? It can directly communicate with the task scheduler while wait() can’t (to my knowledge).
I’m talking about the update rate. I haven’t heard of this task scheduler thing, but in the end, even if wait() were to be a bit less performant in that sense, it updates twice as slow. That’s got to make up for the indirect/less efficient checks, and more.
As for your third question, I believe the above covers it too.
When u say not random, are you looking for equal number of hits between map1 and 2? You can literally get 100 hits on map1 before getting a hit on map2 and it’s still totally random.
The function math.random does not return a truly “random” number. No computer can do that, yet. Instead, it generates a pseudorandom number. There are ways to make the random number generator more random, but it isn’t possible to generate a true random number.
All of these replies are an awkward way of doing this. The reason it isn’t random is because every time the game is started, the seed is the same.
To fix this, try this instead:
math.randomseed(time() * tick())
local randomNumber = math.random(1, 2)