Animation getting called from another script

Well… I’m trying to make an object play an animation when i’m looking at it (with raycasts and range check). All goes well and is detected… But the animation is not played.

Went through some testing and well… It seems that this does work:

	void OnGUI()
	{
		if(GUI.Button(new Rect(0f, 0f, 100f, 20f), "Open"))
		{
			GameObject.FindGameObjectWithTag("STOLIK").animation.Play("idle");	
		}
		
	}

Meanwhile this does not :

public GameObject target;
	void OnGUI()
	{
		if(GUI.Button(new Rect(0f, 0f, 100f, 20f), "Open"))
		{
			target.animation.Play("idle");	
		}
		
	}

And… yes. I’m selecting the correct gameobject in the editor.

What am I doing wrong?

Well. It was really dumb. The GameObject that I was selecting a a prefab and not the actual gameobject… Did a compare on them and then a Debug.DrawLine to both of the GOs that I was receiving.

Really dumb.