So I am new to coding and I am trying to make my gun shoot and add a sound. So far I got this code. I haven’t written it and I tryed my best to understand it but I just don’t get why it says the error message.
var Bullet : Transform;
var Spawn : Transform;
function Update ()
{
if(Input.GetButtonDown("Fire1"))
{
Shot();
}
}
function Shot()
{
var pel = Instantiate(Bullet, Spawn.position, Spawn.rotation);
pel.rigidbody.AddForce(transform.forward * 5000);
}
{ if( Input.GetButtonDown( "Fire1" ) )
;var projectile : Rigidbody; var speed = 20; function Update();
if( Input.GetButtonDown( "Fire1" ) );
audio.Play(); var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) );
Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider );
}
I know its messy