When i put local bombstartnew outside the function it does not print the correct color rgb vlue but when it is in the fucntion it does print the correct rgb value of the color
local bombstartnew local function bombTouched(event) if ( event.phase == "began" ) then print(unpack(bombstartnew.fillColor)) Runtime:removeEventListener( "enterFrame", event.self ) event.target:removeSelf() score = score + 1 -- add new score to current score scoreText.text = score end end local function addnewobject() local startingpoint = math.random(display.contentWidth\*0.1,display.contentWidth\*0.9) bombstartnew = display.newRect( startingpoint, -340, 50, 50) physics.addBody( bombstartnew ) local color1, color2, color3 = ragdogLib.convertHexToRGB(randomcolor()) bombstartnew:setFillColor(color1, color2, color3); bombstartnew.fillColor = {color1, color2, color3} bombstartnew.enterFrame = offscreen Runtime:addEventListener( "enterFrame", bombstartnew ) bombstartnew:addEventListener( "touch", bombTouched ) end