How To Repeat a Function a Random Amount

Hello! So I was wondering how I could run an repeat a function a random amount? I know how to do repeat but how would i hook it up to RandomFloatInRange()? Would I have to create a variable?

Hello, you basically just need to use an index variable and the while loop.
index = 0
index < Random(25)

Copy and Paste This


1 Like

Or you could just use the event While Random(20) > 0 :


I like the simplicity, but there’s a significant logical difference between:

  • Loop X times where X is a random value
  • Loop until you roll a 20 sided dice and get 0

For sure, and the larger the random number, the longer the repeat will most likely be.

But it’s not a method I’d be inclined to use myself. However, it may get someone thinking along alternative lines.

you can also use a repeat loop:

That’s cool, I didn’t know that the input value for Repeat was interpreted as an expression!
So I just tested and you can do:
Repeat Random(20) times