I want the sword object and all of its children to change tags, but for some reason it won’t work. It’s probably some obvious problem and I just don’t see it.
function OnMouseUp()
{
var sword = GameObject.FindGameObjectsWithTag("Unequiped");
sword.tag = "Equiped";
}
Note there are two functions to look up GameObjects by tag:
FindWithTag() returns one matching GameObject (returns null if no such object).
FindGameObjectsWithTag() returns an array of matching GameObjects (returns empty array if no such objects).
The way your code is written, you’re asking for an array… but then treating it as if it’s a single object. If you only need the one object, you can just call FindWithTag(). If you want to edit every object, you can loop through the array as described here, setting tag on each object in the array.