(Spaghetti Code Warning) Operator '*' cannot be applied to 'method group'

Hey, so I’m trying to add a score multiplier as a challenge to myself, but since I just started learning Unity & C# I am completely unsure what this error means, nor how to fix it, thanks in advance!

(P.S if there’s a better way to get a score multiplier system rather than doing it the way I did it, that’d also be nice)

void Update()
    {
        if (Time.timeSinceLevelLoad < 6)
        {
            scoreMultiplier = 0.1f;
        }
        else if (Time.timeSinceLevelLoad < 12 && Time.timeSinceLevelLoad >= 6)
        {
            scoreMultiplier = 0.2f;
        }
        else if (Time.timeSinceLevelLoad < 18 && Time.timeSinceLevelLoad >= 12)
        {
            scoreMultiplier = 0.3f;
        }
        else if (Time.timeSinceLevelLoad < 24 && Time.timeSinceLevelLoad >= 18)
        {
            scoreMultiplier = 0.4f;
        }
        else if (Time.timeSinceLevelLoad < 30 && Time.timeSinceLevelLoad >= 24)
        {
            scoreMultiplier = 0.5f;
        }
        else if (Time.timeSinceLevelLoad < 36 && Time.timeSinceLevelLoad >= 30)
        {
            scoreMultiplier = 0.6f;
        }
        else if (Time.timeSinceLevelLoad < 42 && Time.timeSinceLevelLoad >= 36)
        {
            scoreMultiplier = 0.7f;
        }
        else if (Time.timeSinceLevelLoad < 48 && Time.timeSinceLevelLoad >= 42)
        {
            scoreMultiplier = 0.8f;
        }
        else if (Time.timeSinceLevelLoad < 54 && Time.timeSinceLevelLoad >= 48)
        {
            scoreMultiplier = 0.9f;
        }
        else
        {
            scoreMultiplier = 1f;
        }

        ScoreNumber.text = Mathf.RoundToInt(Time.timeSinceLevelLoad) * (scoreMultiplier).ToString;

You don’t call ‘ToString’, put a () on the end of it. Otherwise it’s a reference to the method ToString (hence the error saying “method group”).

Furthermore, I’m willing to bet you meant to multiply by scoreMultiplier BEFORE calling ToString… something like this?

ScoreNumber.text = Math.RoundToInt(Time.timeSinceLevelLoad * scoreMultiplier).ToString();
float scoreMultiplier = Mathf.InverseLerp(0, 54, Time.timeSinceLevelLoad);

If you need to round it to single digit fraction, use the

float scoreMultiplier = Math.Round(Mathf.InverseLerp(0, 54, Time.timeSinceLevelLoad), 1);

Warning: it may not do precisely what you have written out in the bunch of if-elseif-else tree, but close, test it and play around with it, you can modify it if you want.

Edit: oh and if you need it, throw in a scoreMultiplier = scoremultiplier > 1 ? 1 : scoreMultiplier; line.
Keep in mind that I have written these from the top of my head, so it may not work from out of the box, but the essence is the same.

Ah! Thank you very much, that solved the issues,

About the P.S, is there a less spaghetti way to do it, or should I have it done as an if, else if, else statement for now?

Yeah, if you can come-up with a mathematical formula to get the scoreMultiplier from timeSinceLevelLoaded. It looks like scoreMultiplier is something pretty close to (timeSinceLevelLoaded/60) and then rounded.

See my post above yours. Something like that.

Ah cool. Didn’t notice that. Looks like you’ve already supplied the formula in question.