Find Keyword in a Searched GameObject (JS)

Hello, I’ve currently got a complex turn based game which I working on but I need a quick bit of help with this dilemma.

How do I find and then destroy a gameObject with a keyword in it?

I’ve got something like:

if (GameObject.Find(KeywordA in this name of the gameObject)) {
then go ahead and Destroy(this gameObject);
}

So if I have many objects named “TestingObject5 Movement=(A different random number)” and a few named “TestingObject4 Movement=(A different random number)”, and KeywordA is “TestingObject5”, it will destroy all the objects with the name of “TestingObject5 Movement=(A different random number)”.

Thanks for the help.

You can use tags and then do something like:

  public Object yourObjectNames;
 yourObjectName= GameObject.FindGameObjectsWithTag("Respawn");
 foreach (Object yourObjectName in yourObjectNames) {
            Destroy(yourObjectName,0.0F); 
        }

FindGameObjectsWithTag Manual

Tags Manual Page

Ended up using:

var SceneObj : GameObject [];

function FixedUpdate () {
SceneObj = FindObjectsOfType(GameObject) as GameObject[];
}

function CreateTurnObj () {
for (var i=0; i < AllSceneObj.length; i++){
if(SceneObj*.name.Contains("Turn=" + TurnPlace)){*

print (SceneObj*.name);*
}}}
The one restriction is it can cause lag (i haven’t noticed it) if this is used on a scene with a lot of objects.