Instantiate creates a lot of prefabs

if(Input.GetKey(KeyCode.Space)) {
Instantiate(Shut, new Vector3(transform.position.x, transform.position.y + ( transform.localScale.y * shutDistance ), transform.position.z), Quaternion.identity);
}

When I press ’ Space ’ a lot of prefabs are instantiated, how can I create just only one prefab.

This Instantiate creates more than one item is not my case.

Input.GetKey checks the current state of a key. Since Update runs at a rate around 60 times per second and it’s almost impossible to press a button for only 1/60th of a second of course as long as you hold down your shift button you will instantiate a new object every frame.

For that reason we have a method that checks the actual key down or key up event. Specifically Input.GetKeyDown or Input.GetKeyUp will be only true for one frame when the actual event occurred.