Change Scene inside Timer or onComplete of Animation

When I try to change scene INSIDE a timer or animation I get this error:

bad argument #-2 to 'insert' (proxy expected got nil)

The error points me to the line where the storyboard.gotoScene function is.

I tried to simplify the gotoScene passing as an argument only the scene but it didn’t work

If I change scene outside a timer or animation everything seems to work well

Any suggestions on how to fix it?

Can you post some code?

Can you post some code?