Scripting - need help to make my script shorter

Hi,
I’m not very good in scripting, i’ve never made c# before using Unity.
So i try to do my best but sometimes, it’s not very compact and light.

So i’m here to ask your help about this code, that i would like to make shorter / more compact.

using UnityEngine;
using System.Collections;

public class Coins : MonoBehaviour
{
      public float cash;

voidUpdate(){
      if(TileManager.score==1)
      {
            if(TileManager.score==3)
            {
                  if(TileManager.score==7)
                  {
                        if(TileManager.score==10)
                        {
                              something like cash = cash + 100
                        }

ETC ... ... ... ...

                        else
                        {
                              something like cash = cash + 150
                        }
                  }
                  else
                  {
                       something like cash = cash + 50
                  }
            }
            else
            {
                 something like cash = cash + 30
             }
      }
      else
      {
            something like cash = cash + 10
      }

Maybe my code is wrong, i have not test it yet because i don’t want to have this huge code if another way, more compact, to make it exist.

Thank you in advance for your help, have a nice day :slight_smile:

Hello, I’m learning too, but I’ll try to maybe help you. I created the other script too simulating your other script.
Well, In the other script I have this:

TileManager.cs

and in the script you’re trying to do, I have this:

Cash.cs

I tried, and worked pretty damn well.

I hope I helped you. :smiley: