I can't figure out why this code isn't working. The object does have physics enabled, and the "unprojected" object is in the game.
Unprojected = getObject("Unprojected")
clicked = false
function Click(objectName,camera)
    --[[----------------------------------------------------------------------UNPROJECTED POINT]]
    mx = getAxis("MOUSE_X")
    my = getAxis("MOUSE_Y")    
    V1 = getUnProjectedPoint(camera, vec3(mx, my, 0))
    V2 = getUnProjectedPoint(camera, vec3(mx, my, 4))
    point, Unprojected = rayHit(V1, V2) -- note that rayHit only detects objects with physics enabled
    
    
    if point then --if there is a collision between camera and a point (x,y,z) where x is mouse position, and y is mouse position and z is extended in front...
        Xname = getName(Unprojected)
        Xobj = getObject(Xname)
        --setText(text,Xname)
        --print(Xname)
        
        if Xname == objectName and onKeyDown("MOUSE_BUTTON1") then 
            deactivate(Xobj) 
            playSound(sound) 
            clicked = true 
        --[[else 
            clicked = false --]]
        end
    end
        
end    
function onSceneUpdate()
    Click("monkey",mainCamera)
end