Saving Image to Device

Im making an app where someone takes a picture and then moves an image on top of the photo. I put the photo and the image that gets moved on top into a group called “g”. I want to save the group as one image. I tried this, and when I press my button to save it on my phone, it asks me if i will allow the app to acess my photos, but when I press yes, the photo doesnt save. Im not sure if I am saving it wrong(or to the wrong place). I tried to save just one of the pictures instead of the group and it didn’t work, so its not the fact that Im saving a group. Also, as a side note, if anyone knows how to overlay an image onto the screen when I open the camera it would be very helpful.

Here is the important part of the code Im using for saving:

[lua]

local function onSaveBtnRelease()

media.save( g, PhotoLibrary )

    

    return true

end

[/lua]

Thanks