How to Instantiate prefab as child? (Java)

I am trying to Instantiate prefab (weapon) on a transform. This is script I found online but it doesn’t work giving error:

var Weapon1 = Instantiate(GunType, Weapon1Spawn.transform.localPosition, Weapon1Spawn.transform.localRotation);
Weapon1.transform.parent = Weapon1Spawn.transform;

Error I get with that:
79536-016899bee74d4c67857b2c69ff90de24.jpg

When you instantiate the 4th argument is the parent, for example

Instantiate (prefab, position, rotation, parent transform);

in your case, that would be:

var Weapon1 = Instantiate(GunType, Weapon1Spawn.transform.localPosition, Weapon1Spawn.transform.localRotation, Weapon1Spawn.transform;);