change opacity or something else frame by frame.

Use animation. Don’t use code.