Basketball Game: Need Help!

I am trying to make it so that the player can only shoot once using a boolean, but the ball is still shot even after the boolean is set to true…

var ballPrefab : GameObject;
static var BallShot = false;
function Update () {
// Shooting Ball
if(Input.GetMouseButtonUp(0)){

if(BallShot == false){
var Basketballs : GameObject = Instantiate(ballPrefab, transform.position, transform.rotation);
var BallShot = true;
Debug.Log(BallShot);
}

if(BallShot == true){
Debug.Log("You don't have a ball!");
}
}
}

What is wrong?

but wait a moment… what’s the var-keyword doing in front of BallShot = true;? You already define BallShot as static var at the beginning of the script. (I’m confused you don’t have a compile-error…??)

Is the function that sets the BallShot to false in the other script a static function? Did you delete the script from your project altogether or just remove the instances of the component? Are you sure, you removed ALL instances?

Addition/Edit: Oops O_o Sorry @aldonaletto I posted this as an answer, then decided it should go in a comment after all, because I thought it was not really an answer but just a guess. But meanwhile aldo had commented and I didn’t see it but deleted the answer (and his comment along with it)

Here’s what he said:

That’s the problem: the var keyword
creates a local variable named
BallShot and sets it to true - but the
original BallShot is never changed.
The var keyword must be removed - and
BallShot must be cleared somewhere to
allow new shoots.

Greetz, Ky.

var ballPrefab : GameObject;
static var BallShot = false;
function Update () {
// Shooting Ball
if(Input.GetMouseButtonUp(0)){

if(BallShot == false){
var Basketballs : GameObject = Instantiate(ballPrefab, transform.position, transform.rotation);
var BallShot = true;
Debug.Log(BallShot);
}

if(BallShot == true){
Debug.Log("You don't have a ball!");
}
}
}

You are never setting ballShot to false. Are you sure that is not connected to the problem. Or are you referring to this variable in another script since it is static?

I would have made a comment instead of a answer, but I cant add a comment for some reason.