plz help me I cant figure out what I'm doing wrong. It's says Assets\Scripts\Store.cs(21,25): error

public class Store : MonoBehaviour
{
float CurrentBalance;
float BaseStoreCost;
float BaseStoreProfit;

int StoreCount;
public Text StoreCountText;
public Text CurrentBalanceText;

float StoreTimer = 4f;
float CurrentTimer = 0;
bool StartTimer;

// Start is called before the first frame update
void Start() {

StoreCount = 1;
CurrentBalance = 6;
BaseStoreCost = 1.50f;
BaseStoreProfit 0.50f;
CurrentBalanceText.text = CurrentBalance.ToString(“C2”);
StartTimer = false;
}

// Update is called once per frame
void Update() {
if (StartTimer)

{

CurrentTimer += Time.deltaTime;
if (CurrentTimer > StoreTimer)
{

StartTimer = false;
CurrentTimer = 0f;
CurrentBalance += BaseStoreProfit;
CurrentBalanceText.text = CurrentBalance.ToString(“C2”);

}

}

}

public void BuyStoreOnClick()
{
if (BaseStoreCost > CurrentBalance)
return;
StoreCount = StoreCount + 1;
Debug.Log(StoreCount);
StoreCountText.text = StoreCount.ToString();
CurrentBalance = CurrentBalance - BaseStoreCost;
Debug.Log(StoreCount);
CurrentBalanceText.text = CurrentBalance.ToString(“C2”);

}

public void StoreOnClick()
{
if (StartTimer == false)
StartTimer = true;

}

}

You’re missing a = on BaseStoreProfit 0.50f;.

Also, please use Code tags next time.

hey i’m having a hard time getting this to work. i am following this

plz help me i no i am annoying

public class Store : MonoBehaviour 
{
    float CurrentBalance;
    float BaseStoreCost;
    float BaseStoreProfit;


    int StoreCount;
    public Text StoreCountText;
    public Text CurrentBalanceText;

    float StoreTimer = 4f;
    float CurrentTimer = 0;
    bool StartTimer;

    // Start is called before the first frame update
    void Start() {

        StoreCount = 1;
        CurrentBalance = 6;
        BaseStoreCost = 1.50f;
        BaseStoreProfit = 0.50F;
        CurrentBalanceText.text = CurrentBalance.ToString("C2");
        StartTimer = false;
    }

    // Update is called once per frame
    void Update() {
        if (StartTimer)

        {

            CurrentTimer += Time.deltaTime;
            if (CurrentTimer > StoreTimer)
            {

                StartTimer = false;
                CurrentTimer = 0f;
                CurrentBalance += BaseStoreProfit;
                CurrentBalanceText.text = CurrentBalance.ToString("C2");

            }
     
        }
       

}

    public void BuyStoreOnClick()
{
    if (BaseStoreCost > CurrentBalance)
        return;
    StoreCount = StoreCount + 1;
    Debug.Log(StoreCount);
    StoreCountText.text = StoreCount.ToString();
    CurrentBalance = CurrentBalance - BaseStoreCost;
    Debug.Log(StoreCount);
    CurrentBalanceText.text = CurrentBalance.ToString("C2");


}

public void StoreOnClick()
{
    if (StartTimer == false)
        StartTimer = true;

}

}

this is the youtube video i follow but i can’t figure out what I am doung wrong

You need to tell us what is not working.

I don’t understand what they mean

It looks like you’re missing the ‘using’ statements that are supposed to be at the top of the script. These let the compiler know which namespaces to look at when referencing classes and such that are used throughout.

okej so i put using UnityEngine in the script and it worked so what should i do to get away these two errors

This is going to sound like a cop-out (and maybe somewhat harsh) response, but honestly the best thing you could do at this point would be to back up like 10 steps and start learning how to Google things.

I honest-to-God am not saying that trying to be a jerk. It’s just that you are going to run into many, many, MANY errors while working on a game project, and if you have to rely on people in the forums telling you exactly how to fix each one, you’re going to have the most frustrating experience of your life.

Instead, you can just copy the text out from that console log and paste it into Google, and chances are one of the top 5 results will inform you exactly of what’s going on. Learn how to read the error messages themselves, as they also tell you exactly where the issue is happening. So once you know why things aren’t working, and you figure out how to see where it’s going wrong, all you have to do at that point is spot the issue and fix it yourself!

If you’re overwhelmed at even the thought of writing your own code that isn’t following along with a tutorial video, you may want to proceed with getting comfortable in C# before trying to work with the Unity API. I know Unity’s marketing material would have you believe that it’s super easy to just jump in and start creating your dream game idea, but unfortunately that is a lie that isn’t serving new developers well. There’s a lot you need to learn or at least be familiar with before you should even think about starting on a game idea that’s more complicated than Pong. You can feel free to skip all that stuff (as many beginners do), and I can promise you that where you’re at now will be where you stay for as long as you’re willing to deal with the frustration before giving up.

Take your time, start at the beginning, and learn how to crawl before you try running headfirst into things.

1 Like

okey and all but how am i going to learn if i just stop. Could you at least say where to go and learn coding

I mean, sure, if you really want

The Yellow Book is widely regarded as a great starting resource for new C# devs, and you can download it for free from that link. Otherwise, I would think literally any course that teaches C# would be an option that puts you in a better position than you are now.

And I just want to state for clarification: I am not saying you should stop. I’m saying you skipped a bunch of steps you need to know in order to succeed at the level you’re trying to run at now. Go back and do those, and when you get back to this stage, you’ll be ready!

okey so you think all I would need is in that book.

Thank you BTW!

No idea about that OnGUIDepth error, but the second error tells you that you’re missing a semicolon at the end of Line 1.

For reference: A newly created C# script (right click in your Project window > Create > C# Script) looks like this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
    
    }

    // Update is called once per frame
    void Update()
    {
    
    }
}

It’s definitely not all you need, but it’s a good place to start.

You’re very welcome! I know it’s not fun hearing someone say that you need to go back and do a bunch of stuff that isn’t fun, but being receptive to advice is a good indicator that you’ll be able to figure all this stuff out. Keep at it!