Script for Selecting all Objects with 'Tag' and checking 'is Kinematic'

Here is my script so far…

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MakeKinematic : MonoBehaviour
{
void Start()
{
GameObject[ ] ImportedObjects;
Rigidbody rb;

ImportedObjects = GameObject.FindGameObjectsWithTag(“ImportedObject”) ;

foreach (GameObject io in ImportedObjects)
{
rb = GetComponent();
rb.isKinematic = true;
rb.detectCollisions = false;
}
}
}

I only want this to happen during an event at Runtime (not start-up). I currently attached the script to an object, and then I set that object ‘active’ when I am ready for it to run. It appears to have selected the object that the script is attached to (which does not have the tagname 'ImportedObject").

Am I missing something? Thanks for any help.

Use code tags !

GetComponent gets the component from the gameobject your script is attached to. You want:

foreach (GameObject io in ImportedObjects)
{
    rb = io.GetComponent<Rigidbody>();
}

Thank you very much!