FPS working but ..... frequency on shoot

hi …
I have an First Person Shooter working niche
but when I hold down the mouse button

shoot bullets to much

i need only one shoot, even if held down mouse button
like sniper.

but, of player press very fast the mouse button
then shoot fast on each pressed.

in other words
just need one bullet on every mouse press

on my logic is something like this:

if mouse press = shoot one
if mouse held press = shoot one

here is my whole code
please help

thanks so much for any help

var fireRate = 0.05;
var nextFireTime = 0.05;
var bulletsLeft = 100;
var projectileStd : Rigidbody; 
var initialSpeed = 30.0; 

function Update () 
{ if (Input.GetButton ("Fire1"))
{
Fire ();
} }

function FireOneShot () 
{var projectile: Rigidbody;
projectile=projectileStd;

if(projectile)
{
var instantiatedProjectile : Rigidbody = Instantiate (projectile, transform.position, transform.rotation); 
instantiatedProjectile.velocity = transform.TransformDirection(Vector3 (0, 0, initialSpeed)); 
} }

function Fire ()
{
if (bulletsLeft == 0)
return;
   
// If there is more than one bullet between the last and this frame - Reset the nextFireTime
if (Time.time - fireRate > nextFireTime)
nextFireTime = Time.time - Time.deltaTime;
   
// Keep firing until we used up the fire time
while( nextFireTime < Time.time  bulletsLeft != 0)
{
FireOneShot();
nextFireTime += fireRate;
} }

Hi mate, try using Input.GetButtonDown instead of Get.Button

thanks you !!!
thanks you !!!
thanks you !!!

so much !!!

:lol: Thats cool