gameObject.tag by scripting

Excuse me, I have problem here, I want to tag this clone. I write it like this and it give me the error at tag line, the object spawn but git the error and still no tag. What wrong I do here ??

Public GameObject clone;
Public string tag;

clone = Instantiate(prefab,new Vector3 (105, 689, 0), Quaternion.identity) as GameObject;
clone.gameObject.tag = "copy";

You have to define tags before you use them.

1 Like