“attempt to index a nil value”-error in Lua

You’re not returning anything from your function call. Also, use local variables inside functions.

function newImage(Image, posx, posy)
    local pic = Bitmap.new(Texture.new(Image)) 
    stage: addChild(pic)
    pic:setPosition(posx,posy)
    return pic
end

Leave a Comment

tech