Im currently trying to make a basic clicker game to start to teach myself how to do C# and i've been able to resolve most problems with this part but not yet. Right not I'm programming a buyable upgrade that generates money on it's own which I think I got down but theres an error with one of the if statements and I don't know to fix it. Does anyone else know what I did wrong?
Code:
private int a = 0;
private void flatButton1_Click(object sender, EventArgs e)
{
a++;
flatTextBox1.Text = a.ToString($"Knowledge: {a}");
}
private void flatButton2_Click(object sender, EventArgs e)
{
if (a >= 50)
{
bool upgrade1 = true;
}
if (upgrade1 == true)
{
for ( ; ; )
{
a = a + (a++ * 2);
}
}
The only thing that is giving an error is the if(upgrade1 = true), the upgrade1 is the error, it says that The name 'upgrade1' does not exist in the current context.