Hi!
* Please use code tags when posting code. *
What you are trying to do could be done via scripting, but would probably be easier handled with an Animator controller. You can create an animation for any object by selecting it and hitting Ctrl + 6.
Brackeys has a tutorial for fade in screens, but the same principle can be applied to objects.