Bug with variables

I created a variable for saving randomized numbers. First, i put the code like this:

Reg = 17500 + random(0, 2000)
wait(Reg)

And it doesn’t works. The code didn’t wait at all!

After that, i wrote the code like this:

Reg = 17500 + random(0, 2000)
...
wait(Reg)

And it works! But this is annoying… Very annoying.

Does it happens to you?
  • Yes
  • Yes, and i know why does it happens
  • Nope

0 voters

If you know why it happens pls tell me!

3 Likes

What is the

3 Likes

Any code in between, such as Wait seconds 0.

3 Likes

What does wait 0 do?

3 Likes

Maybe the variable takes more than 1 frame to update, and the wait block cannot execute / is skipped.

3 Likes

Basically gives code an extra frame to execute before it executes the next set of code…

4 Likes

It might be setting it as a string and not converting it properly…

3 Likes

oh yes good idea! Thanks!

2 Likes

Hmm nah i don’t think so lol

4 Likes

What do you mean?

4 Likes

Not sure, I’m not a master at coding… too hard to explain…

5 Likes

can I have a link?

5 Likes

I think that this might happen if it’s when game starts, because the wait happens almost immediately after you set your variable (reg). The code probably isn’t prepared to wait so early in the game, I don’t know why this is, but it’s the only explanation I can think of. To fix this, try putting a couple wait seconds (0) or set invisiblility percent to (whatever percent it was already set to) and other blocks that won’t really do anything at that point in the code. This actually works.

1 Like

@Nobody Sorry, i want to keep my project secret for the moment ):
@DolphinGirl7 Thanks!
@Leaders pls close this topic the problem is solved

2 Likes

Btw @Nobody i’ll publish this project next week and my name on hs is NTh3R