When duplicating objects that have logic bricks already set up, only the most recently duplicated object will actually function properly. here is a very simple example of what is happening. the cube on the right is a duplicate of the one on the left. if you press play, only the cube on the right will run the script properly by teleporting around and changing color ever second. if you delete the cube on the right, the one on the left will work just fine. if you duplicate either of the cubes, only the newly created cube will work.
what is going on here? is there any way to fix this?
Basically you were having two objects run the module and the one that ran last would overwrite the own variable for both objects (Since it is a module) since the own varibale was never rewritten it used the last value given to it (The second object) and just did that. (I suggest moving other variables needed into the repeating action such as cont)
A simple test was to put a print(“RUN”) in there and see that it was printing twice for every one color movement.
Generally avoid any module-level variables when using module mode.
For example, the amended code will fail when run in a different scene if you were to use the scene variable.
You actually do not need to look up the current scene or controller - module mode provides the controller, and the owner of the controller is a KX_GameObject instance, which has a scene attribute.