How to move something based on random?

Hi, I’m having issues moving pipes depending on a random number generated on this Flappy Bird game. The code I have tried is here:

 var movePipes2 = function() {
        var rnd = Math.random();
        var item =;

        if (rnd > 0 < 0.33) {
            item.translateLocal(1, 0.1, 0);
        if (rnd > 0.33 < 0.66) {
            item.translateLocal(2, 0.1, 0);
        if (rnd > 0.66 < 1) {
            item.translateLocal(3, 0.1, 0);

But this does not seem to be doing anything? I have tried other things, like instead of using
translateLocal, I used setLocalPosition, and setPosition, but none of these have seemed to work.

Any help is appreciated :slight_smile:

What errors do you get in console if any?

There are no errors that appear, it just does not seem to work :confused:
I’m thinking it might be because of the;

That’s surprising. I expect that function to throw a bunch of errors. Is that function being called as I see it being declared as a global function?

It is a global function, I have even tried putting it at the end of a script, and as it’s own script, and no errors have occurred nor has it worked :confused:

But is the function itself being called anywhere in the game?

No, apart from what I am trying to do.

You have a few issues regarding this specific code.

  1. You have created two function objects in global space that have the same name. In movePipes.js and pipe-height.js. This means in the best case, one function is going to override the other.

  2. You are not calling that function anywhere in the code base so it doesn’t matter what’s in the function because it is not being executed.