Placing brackets in a script

Hello everyone. I’m working on a game right now and I tried to make a script for a shooting bow. This is the first script I’ve really written on my own and I need help placing brackets. If someone could show me where to put the brackets and also explain in general where to put them it would be greatly appreciated.

#pragma strict

var Weapon01 : GameObject;
var Weapon02 : GameObject;
var Ammo : int; 
var projectile : Rigidbody;
var speed = 10;
var nonex;
var snonex;
var FireRate : float = 1.0;

private var NextFire : float;

function Update ()
	if (Input.GetKeyDown(KeyCode.R));
		if (Ammo > 0)
 nonex = true;

function SwapWeapons()

if ( == true);



if nonex = true{
//play animation
//play sound

snonex = true 

if snonex = true 
	if (Input.GetButtonUp("Fire1") && Time.time > NextFire)
	NextFire = Time.time + FireRate;

clone = Instantiate(projectile,transform.position,transform.rotation);
clone.velocity = transform.TransformDirection(Vector3 (0,0 speed));

NextFire = Time.time + FireRate;


Brackets define a scope. A variable exists within the brackets in which it is created:

{ // Scope A
    float f = 0.0f;
    { // Scope B
        float g = 0.0f;
        f = 10.0f; 
    g = 10.0; // Error
{ // Scope C
     // f and g do not exist

What is created in scope A also exists in scope B since Scope B is nested. What is created in scope B only exists in scope B and any nested scopes (none in this case).
Scope C does not see what was created in Scope A or B and vice-versa.

Scopes are used to define methods, actions or even classes/structs. What is created in a class can be seen outside of its scope by using access modifiers (public, protected, internal).

Brackets define the limits of an action like an if/switch/while and so on:

{ }
else if(other){}

if the content is only one line, the brackets are not used.

if(condition)  MyAction();

I tend to avoid this since it loses readability:

     MyAction();  // Bad according to me.


MyAction() always run though one may wrongly think it is part of the if. Particularly if there is a lot of other conditions all around and indentation is badly done.

Same applies for variables, whatever is created in the if does not exist in the else if or anywhere else.

Brackets are used thusly:

function FunctionName(parameters)
 Stuff that happens inside function are enclosed by brackets

the same applies for if:

if(something happens)
 Do stuff
else if(something else happens)
 Do stuff
 Do stuff