Print color of object not wokring

Not sure exactly what you’re looking for… but you can print/access the fill color of a display object by doing this:

print(myObject.fill.r, myObject.fill.g, myObject.fill.b)

If you want that in RGB (0>255)

print(myObject.fill.r / 255, myObject.fill.g / 255, myObject.fill.b / 255)

I am expecting an rgb value here is full code

local ragdogLib = {}; ragdogLib.convertHexToRGB = function(hexCode) assert(#hexCode == 7, "The hex value must be passed in the form of #XXXXXX"); local hexCode = hexCode:gsub("#","") return tonumber("0x"..hexCode:sub(1,2))/255,tonumber("0x"..hexCode:sub(3,4))/255,tonumber("0x"..hexCode:sub(5,6))/255; end return ragdogLib;

local physics = require( "physics" ) physics.start() local ragdogLib = require "ragdogLib"; function randomcolor() local colors = { "#e67e22","#e74c3c" ,"#f1c40f","#1abc9c","#8e44ad" } local finalcolor = colors[math.random(1, 5)] return finalcolor end local function bombTouched(self,event) if ( event.phase == "began" ) then print(unpack(self.fillColor)) Runtime:removeEventListener( "enterFrame", event.self ) event.target:removeSelf() self = nil 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) local 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:addEventListener( "touch", bombstartnew ) Runtime:addEventListener( "enterFrame", bombstartnew ) end timer.performWithDelay(500, addnewobject,0)

The code in the OP will always print the colour of the most recently created one because you’re doing

print(unpack(bombstartnew.fillColor))

rather than

print(unpack(event.target.fillColor))

which would print the colour of the one you’d touched