What should I change in this instantiating a GameObject in a script using Unity?

I am trying to instantiate a GameObject using C# in Unity. It won’t face the right direction or appear in the right position. Here is my script -

Instantiate(magicmissile, transform.position, transform.rotation);
basicattackcooldown = 50;

I believe my syntax concerning the transform.position and transform.rotation is incorrect. What should I change to correct it?

When you call your Instantiate code and use transform.position and transform.rotation, you’re using the transform information from the Game Object that the code is attached from, not the prefab that you’re wishing to instantiate.

You need to provide the vector3 location that you want it to spawn at, and if you want no rotation on the prefab you need to use Quaternion.identity instead of transform.rotation.