Hi I’m making an ammo script and I have been looking through other questions but I cant really seem to find my problem in them. When I call my “reserveAmmo” I am receiving an error: Cannot implicitly convert type 'string ’ to ‘UnityEngine.UI.Text’. I have been using ToString() on other parts of my code but for some reason it does not seem to be working…
const int capacity = 10;
int currentClip;
int reserveAmmo = 20;
// GUI Ammo
public Text clipText;
public Text ReserveAmmoText;
public Text ReloadText;
void Start ()
{
clipText.text = "Clip : " + capacity.ToString();
ReserveAmmoText = "Reserve Ammo : " + reserveAmmo.ToString(); //error is here
}
void Update () {
if (gun.active)
{
if (Input.GetButtonDown("Fire1"))
{
int x = 110; for (int i = 0; i < currentClip; i++) ;
x += 8;
if (currentClip > 0)
{
currentClip--;
}
else
{
if (reserveAmmo > 0)
{
if (Input.GetButtonDown("R"))
{
currentClip = capacity;
reserveAmmo -= capacity;
}
}
}
}
}
}
I have cut out a bunch of code that I don’t think is necessary so there might be the odd missing or too many bracket. Thanks for help if anyone can help me!