Error with getLinearVelocity() when nil

Hi,

I am looking through the objects in my game checking the getLinearVelocity() and sometimes I get an error: attempt to call method getLinearMethod (a nill value)

Is there any way to check if it is nil before calling? I tried the code below to check and still gave an error.

 if shoe:getLinearVelocity() ~= nil then local sx, sy = shoe:getLinearVelocity()

Thanks!

if (shoe.getLinearVelocity) then local sx, sy = shoe:getLinearVelocity() end
if (shoe.getLinearVelocity) then local sx, sy = shoe:getLinearVelocity() end