gun shooting script, gun activation script if you help me solve it when i solve it i will post it here so anyone can use it

I had a problem with this script of my game to shoot the pistols and I got this error error CS1525: Invalid expression term can you help me and I tried to solve it but I could not this is the script

On line 15, you must use the new Vector3(). try changing line 15 to like this:

instantiatedProjectile.velocity = transform.TransformDirection(new Vector3(0,0,speed));

This is because you need to instantiate a new class to set a new value for the vector. indicate that you are calling a constructor and not just any method that returns an object. And serves to prevent an instance with a null attribute from existing.

It turns out that you put a “.” after the GetComponent, but you don’t need the dot. GetComponent();

try changing like this:

Physics.IgnoreCollision(instantiatedProjectile.GetComponent< Collider > (),
transform.root.GetComponent< Collider >());