How to call an object inside a function?

How to call an object inside a function? Example: The “pencil” object is inside a function, and after closing it, I have to use

 pencil:removeEventListener ("touch", moveLapis)

how do I do that?

For when I call it normally, an error saying that the pencil is NIL

baka yung Lapis mo naka local, try mo i global(Assuming that you are a Pinoy)

maybe your pencil is in local, try making it global, so as the function moveLapis make it global, also in the function, “return true” so that you can still take hold of the object.

baka yung Lapis mo naka local, try mo i global(Assuming that you are a Pinoy)

maybe your pencil is in local, try making it global, so as the function moveLapis make it global, also in the function, “return true” so that you can still take hold of the object.