Single Shot to Full Auto and vice versa

New to scripting and unity so i am learning… i hope my question does not seem too ignorant.

I know i can do a switch weapon script to do this, but im wondering how could i keep the same weapon selected but change “fire modes”.

Here is the function which determines either:

if( ShootTimer > 0){

ShootTimer -= Time.deltaTime;

}

if(ShootTimer < 0 ){

	ShootTimer =0;

	}
	
	if( KeyTimer == 0){
if(Input.GetMouseButton(0) && BulletsLeft){
if( ShootTimer ==0){

	
	PlayShootAudio();
	RayShoot();
	
		ShootTimer = ShootCooler;

	}
	
	if(muzzleFlashTimer ==0){
	
		muzzleFlashTimer = muzzleCooler;
			
				MuzzleFlashShow();

}

I can simply change if(Input.GetMouseButton(0) to if(Input.GetMouseButtonDown(0) to get the Auto and Single shot.

What do i need to add/change to get my desired effect?

Thanks in Advance!

What you're asking is very, very simple. All you need to do is add a boolean 'fullAuto', and then replace the line

if(Input.GetMouseButton(0) && BulletsLeft){

with something like this:

if(Input.GetButtonDown("FireMode"))
{
    fullAuto = !fullAuto;
}

var shouldFire : boolean;
if(fullAuto)
{
    shouldFire = Input.GetMouseButton(0);
} else {
    Input.GetMouseButtonDown(0)
}

if(shouldFire && BulletsLeft){ // and so on!

Well, you could have a boolean that is changed by pressing a button let’s call it oneshot
Then

if (oneshot){
if (Input.GetButtonDown){}}

else if (!oneshot){
if (Input.GetButton){}}

I don’t know if this is the best way but that could be a lead.

It checks if oneshot is true or false and then do the proper action GetButtonDown only performs once when going down, GetButton keeps shooting when button is held down.
Main problem is that the boolean checking happens even though you are not pressing the button hence taking resources.
Just trying to help though.