starting an animation attached to a different object trough code

I made a 3dtext, which has a script attached to it. If it gets clicked, an animation should start.
But the animation is from a different gameobject.

You need a reference to the game object. If its always the same one just add a public field of the type GameObject and configure it in the editor. If it needs to be configured at runtime.

There are many ways to do that from passing the reference around to finding it by tag. It really depends on your requirements to which is most appropriate.