This is my gun script. The only part that doesn’t work is the reloading part. Every time I press r, it doesn’t reload. I am a beginner at Javascript, so I really could use your valuable knowledge. Thanks.
#pragma strict
var shot : GameObject;
var shootingObject : GameObject;
var ammo : int;
function Start () {
ammo = 15;
}
function Update () {
if(Input.GetButtonDown(“Fire1”)) {
if(ammo > 0) {
ammo --;
var projectile = Instantiate(shot, transform.position, transform.rotation);
projectile.rigidbody.AddForce(transform.forward *6000);
if(Input.GetKey("r") ) {
ammo += 10;
}
}
}
}