I am currently wondering how I can have chances/% of an event happening?
I tried looking up on the devhub or on YouTube but didn’t find much results.
Here’s a brief example of what I want to achieve.
-- Code of the chances, can be a bit like a wait() command if it helps
—[[
There’s a 50% chances of being true.
If false then repeat wait(1), as a delay, until it is true.
When true we move on the next line of codes.
—]]
—
--Code executed after the chances were made. So if true, these lines of codes would execute.
print(“Moving”)
Hopefully it does as you wanted, although I’m not too sure if I understood what you had mentioned well.
To explain what it does, it first sets a value in the variable, if the random number was 1, it sets true into the val, otherwise, false. If val is true by the time it reaches that while loop, it just continues on, otherwise, does what you wanted (wait 1 second and try again until the value is true)
After trying @EmbatTheHybrid‘s way, it worked! Thank you! Now there was a few changes like rn it’s (1, 100) <= to make it in percent but I decided I will make it (1,20) to represent FNAF AI.