Script gives off error I can't fix

BossTarget.TakeDamage(bossdamage);

The error: 56,17): error CS0120: An object reference is required for the non-static field, method, or property ‘BossTarget.TakeDamage(float)’

Here is the full code

using UnityEngine;
using UnityEngine.UI;

public class Shoot : MonoBehaviour
{
    public float damage = 10f;
    public float bossdamage = 10f;
    public float range = 100f;
    public ParticleSystem muzzleFlash;
    public float maxAmmo = 10;
    public float currentAmmo;
    public float reloadTime = 1f;
    public Text AmmoText;
    private bool isReloading;
    public GameObject WeaponHolder;

    public Camera fpsCam;

    void Start()
    {
        currentAmmo = maxAmmo;
        AmmoText.text = currentAmmo.ToString();
    }
   
    void Update()
    {
        bossdamage = damage;
        if (currentAmmo <= 0)
        {
            StartCoroutine(Reload());
            return;
        }
       
        if (Input.GetButtonDown("Fire1"))
        {
            AmmoText.text = currentAmmo.ToString();
            Shoot();
        }

    void Shoot()
    {
        muzzleFlash.Play();
        AmmoText.text = currentAmmo.ToString();
        currentAmmo--;

        RaycastHit hit;
        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            Debug.Log (hit.transform.name);
            Target target = hit.transform.GetComponent<Target>();
            if (target != null)
            {
                target.TakeDamage(damage);
                BossTarget.TakeDamage(bossdamage);
            }
        }
    }
   
    IEnumerator Reload ()
    {
        isReloading = true;
        Debug.Log("Reloading...");
        AmmoText.text = "Reloading...".ToString();
       
        yield return new WaitForSeconds(reloadTime);
       
        currentAmmo = maxAmmo;
        isReloading = false;
        AmmoText.text = currentAmmo.ToString();

    }
}
   
}

The error: 56,17): error CS0120: An object reference is required for the non-static field, method, or property ‘BossTarget.TakeDamage(float)’

What I can see is that BossTarget.TakeDamage(bossdamage); is giving off the error, but I already have a float there public float bossdamage = 10f;

Fixed

Please consider others that may find this thread in the future and post the solution.

2 Likes

Oh, all I did was remove that float and the line that gave off the error