use the tag of a gameobject to assign a string variable

Hey i have a empty string variable. I want to access the tag name of a gameobject and assign it to my string variable.

public string shiptag;

currently its empty, but i try this way to access the gameobject tag and assign it.

shipTag = aquiredShip.gameObject.tag;

but it doesnt seem to work. Looking in the inspector, the string is still empty.

aquiredShip is the Gameobject i want to access and use its tag.

If acquiredShip is a gameObject, then you’d want:

shipTag = acquiredShip.tag;