Unable to set "y" value on an image.

I am trying to set the y value to an image so I can position it but I keep getting an error message.

What am I doing wrong?

Error Message: Attempt to index local sawone (a nil value)

Here is my code 

-- Creates Saw local function spawnSaw() local singleSaw = display.newImageRect( "images/saw.png", 120, 120 ) singleSaw.x = 70 physics.addBody( singleSaw, "static", {bounce=0, density=2, friction=2} ) end local sawone = spawnSaw() sawone.y=30

You need to put return singleSaw at the end of your spawn function.

You could also do something fun, like this:

local function spawnSaw(a,b) local singleSaw = display.newRect( 0,0, 120, 120 ) singleSaw.x = a singleSaw.y = b physics.addBody( singleSaw, "static", {bounce=0, density=2, friction=2} ) return singleSaw end local sawone = spawnSaw(70,30)

You need to put return singleSaw at the end of your spawn function.

You could also do something fun, like this:

local function spawnSaw(a,b) local singleSaw = display.newRect( 0,0, 120, 120 ) singleSaw.x = a singleSaw.y = b physics.addBody( singleSaw, "static", {bounce=0, density=2, friction=2} ) return singleSaw end local sawone = spawnSaw(70,30)