How to use Insert

hey guys and gals, today  i have been having some trouble   inserting my objects i spawned in a table  to remove when the scene  change. when the scene change the objects stay on screen. so i came to a understanding it not possible to insert a table in a group , so i when a head and research the forum but could find anything. i am not sure it could be a small problem that i never experienced before in Corona.  i like to set up my spawning objects like this 

coinsTable = { "coins/coin06"} coins = {} function spawnCoins() ranNum = math.random(#coinsTable) coins[#coins + 1] = display.newImage( coinsTable[ranNum]..".png" ) coins[#coins].x = math.random(-10, 300); coins[#coins].y = -40; coins[#coins].id = coinsNum transition.to( coins[#coins], {time = math.random(2000, 8000), x = math.random(90, 100) , y = 480, onComplete = nil}); coins[#coins].name = "money" coins[#coins].isFixedRotation = true end timer1= timer.performWithDelay( 1000, spawnCoins, 0 ) --screenGroup:insert(coins[#coins]) -- inserting error line -- error says "try to use : instead of ."

how would i go about removing these objects when the scene change ?

i what am i doing wrong and someone please  point  me in the right direction  thank you :slight_smile:

coinsTable = { "coins/coin06"} coins = {} function spawnCoins() ranNum = math.random(#coinsTable) coins[#coins + 1] = display.newImage( coinsTable[ranNum]..".png" ) coins[#coins].x = math.random(-10, 300); coins[#coins].y = -40; coins[#coins].id = coinsNum transition.to( coins[#coins], {time = math.random(2000, 8000), x = math.random(90, 100) , y = 480, onComplete = nil}); coins[#coins].name = "money" coins[#coins].isFixedRotation = true screenGroup:insert(coins[#coins]) end timer1= timer.performWithDelay( 1000, spawnCoins, 0 ) 

Assuming that screenGroup exists and is a display.newGroup that your scene manager is actually using.

Rob

thank you man it worked  i am very thankful  :slight_smile:

coinsTable = { "coins/coin06"} coins = {} function spawnCoins() ranNum = math.random(#coinsTable) coins[#coins + 1] = display.newImage( coinsTable[ranNum]..".png" ) coins[#coins].x = math.random(-10, 300); coins[#coins].y = -40; coins[#coins].id = coinsNum transition.to( coins[#coins], {time = math.random(2000, 8000), x = math.random(90, 100) , y = 480, onComplete = nil}); coins[#coins].name = "money" coins[#coins].isFixedRotation = true screenGroup:insert(coins[#coins]) end timer1= timer.performWithDelay( 1000, spawnCoins, 0 ) 

Assuming that screenGroup exists and is a display.newGroup that your scene manager is actually using.

Rob

thank you man it worked  i am very thankful  :slight_smile: