As this script work?

Hey guys as work this Script? I need make an object appears by pressing “T”, Sorry the bad english i Speak spanish, Greetings to all!

public Mesh objectToCreate;

void Update()
{
    if(Input.GetKeyDown("T"))
    {
        var gameObject = new GameObject("Some Name Here");
        var meshFilter = gameObject.AddComponent<MeshFilter>();
        gameObject.AddComponent<MeshRenderer>();
        meshFilter.sharedMesh = objectToCreate;
        gameObject.transform.position = transform.position;
        gameObject.transform.rotation = transform.rotation;
    }
}

the syntax for GetKeyDown is not correct. change to

if(Input.GetKeyDown(KeyCode.T))

also, it’s a BAD idea to name the object as gameObject - that’s an internal name which unity uses and may cause bugs/confusion/end of the world. ok, maybe i joke about the last bit :wink: