I know there’s an easy answer to this but I can’t figure it out! I have five objects and I want to randomly select one of those objects and apply force to it. This is what I have, but it won’t work:
[lua]local i = math.random( 1, 5 ) – choose a random number from 1 to 5
object_[i]:applyForce( 10 ) – apply force to the randomly chosen object[/lua]
The error I get is “attempt to index global ‘object_’ (a nil value)”. I’ve already declared the objects as global. What am I doing wrong?
[import]uid: 82194 topic_id: 28447 reply_id: 328447[/import]