[SerializeField] Tag affects the way the code runs?

So this isn’t really important and I’m mostly just curious. So I have a script that allows my character to auto-fire with a float variable for the next time to fire and when that viriable is set to private, the character only fires the first shot, but when that same variable is set to public or has a [SerializeField] tag, it works just fine.

Can someone explain why it behaves this way?
Thanks!

Here’s the script attached

[SerializeField] private GameObject bullet;

 [SerializeField] private float FireRate = 3f;
 private float NextShot = 0f;

private void Update()
    {
        if (Input.GetKey(KeyCode.Mouse0) && Time.time >= NextShot)
        {
            NextShot = Time.time + 1f / FireRate;
            Shoot();
        }
    }

private void Shoot()
    {
        Instantiate(bullet, Fire_Point.position, Fire_Point.rotation);
    }

No, that’s not possible. You should have done more testing. The reason why you only get one shot could be that you set your firerate to 0 in the inspector. This would result in a NextShot value of +infinity so Time.time is never larger than infinity ^^. So check the value in the inspector. Note if the variable was once serialized, Unity will keep that serialized data, even when the field is no longer serialized. If you later mark it again with SerializeField, it would again have the old serialized value. When a variable is serialized, the value you assign in the field initializer becomes meaningless. Only the value serialized is important.