MAYA Visibility question


Dear all,

I am currently trying to do the following. I have 600 cubes and I want to keyframe the visibility over time, meaning that in the first frame cube1 is visible. In frame 2 the visibility of cube 1 is turned off again and the visibility of cube 2 is turned on and so on…

I found the following mel script but it does not work anymore in Maya 2020 (syntax error).

Can anyone help me? I am OK in maya but not good at MEL…