Numspawn counting up without the entities spawning

I have a small game that I have working on for a couple of months already. But my problem is this script…

using System.Collections;
using System.Collections.Generic;
using UnityEditor.UIElements;
using UnityEngine;

public class spawner : MonoBehaviour
{
    //This is GameObject[]    
    [SerializeField] private GameObject[] Entities;
    [SerializeField] public GameObject[] EntitiespatEasy;
    [SerializeField] public GameObject[] EntitiespatModerate;
    [SerializeField] public GameObject[] EntitiespatHard;
    [SerializeField] public GameObject[] EntitiespatVeryHard;
    [SerializeField] public GameObject[] EntitiespatGodmode;
    
    private float TimebtwSpawn;
    public float StartTimebtwSpawn;
    public float decreaseTime;
    public float minTime = 0.65f;

    private int numspawn;
    
    // Update is called once per frame
    void Update()
    {

        Difficutlyrating();
        
    }
    
    //This wil be for Beginner
    private void Spawnedthem()
    {
    
        //This scripts able to force spawn
        if (TimebtwSpawn <= 0)
        {
            int rand = Random.Range(0, Entities.Length);
            Instantiate(Entities[rand], transform.position, Quaternion.identity);
            TimebtwSpawn = StartTimebtwSpawn;
            if (TimebtwSpawn > StartTimebtwSpawn)
            {
                 StartTimebtwSpawn -= decreaseTime;
            }
        }
        else 
        {
            TimebtwSpawn -= Time.deltaTime;
        }
    }


    //This proviate the information what what to spawn
    void Difficutlyrating()
    {
        if(numspawn <= 20)
        {
            Debug.Log("Beginner");
            Debug.Log("Numspawn");
            if (TimebtwSpawn <= 0)
                {
                    int rand = Random.Range(0, Entities.Length);
                    Instantiate(Entities[rand], transform.position, Quaternion.identity);
                    TimebtwSpawn = StartTimebtwSpawn;
                    if (TimebtwSpawn > StartTimebtwSpawn)
                    {
                        StartTimebtwSpawn -= decreaseTime;
                    }
                    numspawn++;
                }
                else
                {
                    TimebtwSpawn -= Time.deltaTime;
                    numspawn++;
                }
            }

     
        //Easy
        if (numspawn <= 40)
        {
            Debug.Log("Easy");
            Debug.Log("Numspawn");
            if (TimebtwSpawn <= 0)
            {
                int rand = Random.Range(0, EntitiespatEasy.Length);
                Instantiate(EntitiespatEasy[rand], transform.position, Quaternion.identity);
                TimebtwSpawn = StartTimebtwSpawn;
                if (TimebtwSpawn > StartTimebtwSpawn)
                {
                    StartTimebtwSpawn -= decreaseTime;
                }
                numspawn++;
            }
            else
            {
                TimebtwSpawn -= Time.deltaTime;
                numspawn++;
            }
        }
        //Moderate
        else if (numspawn <= 60)
        {
            Debug.Log("Moderate");
            Debug.Log("Numspawn");
            if (TimebtwSpawn <= 0)
            {
                int rand = Random.Range(0, EntitiespatModerate.Length);
                Instantiate(EntitiespatModerate[rand], transform.position, Quaternion.identity);
                TimebtwSpawn = StartTimebtwSpawn;
                if (TimebtwSpawn > StartTimebtwSpawn)
                {
                    StartTimebtwSpawn -= decreaseTime;
                }
                numspawn++;
            }
            else
            {
                TimebtwSpawn -= Time.deltaTime;
                numspawn++;
            }
        }
        //Hard
        else if (numspawn <= 80)
        {
            Debug.Log("Hard");
            Debug.Log("Numspawn");
            if (TimebtwSpawn <= 0)
            {
                int rand = Random.Range(0, EntitiespatHard.Length);
                Instantiate(EntitiespatHard[rand], transform.position, Quaternion.identity);
                TimebtwSpawn = StartTimebtwSpawn;
                if (TimebtwSpawn > StartTimebtwSpawn)
                {
                    StartTimebtwSpawn -= decreaseTime;
                }
                numspawn++;
            }
            else
            {
                TimebtwSpawn -= Time.deltaTime;
                numspawn++;
            }
        }
        //Very Hard
        else if (numspawn <= 100)
        {
            Debug.Log("Very Hard");
            Debug.Log("Numspawn");
            if (TimebtwSpawn <= 0)
            {
                int rand = Random.Range(0, EntitiespatVeryHard.Length);
                Instantiate(EntitiespatVeryHard[rand], transform.position, Quaternion.identity);
                TimebtwSpawn = StartTimebtwSpawn;
                if (TimebtwSpawn > StartTimebtwSpawn)
                {
                    StartTimebtwSpawn -= decreaseTime;
                }
                numspawn++;
            }
            else
            {
                TimebtwSpawn -= Time.deltaTime;
                numspawn++;
            }
        }
        //GodeMode
        else if (numspawn >= 100)
        {
            Debug.Log("God Mode");
            Debug.Log("Numspawn");
            if (TimebtwSpawn <= 0)
            {
                int rand = Random.Range(0, EntitiespatGodmode.Length);
                Instantiate(EntitiespatGodmode[rand], transform.position, Quaternion.identity);
                TimebtwSpawn = StartTimebtwSpawn;
                if (TimebtwSpawn > StartTimebtwSpawn)
                {
                    StartTimebtwSpawn -= decreaseTime;
                }
                numspawn++;
            }
            else
            {
                TimebtwSpawn -= Time.deltaTime;
                numspawn++;
            }
        }
    }

}

The problem with the script is that is numspawn counting up even the entities haven’t spawned yet and it just went to the Godmode right on the spot. I know the core problem is the numspawn part but how am I going to solve this. Please help me! I’m quite a C# noob.

You have duplicate code all over the place, I suggest you reduce it to something like 60 rows so it’s easier to read and see what the code does, it’s much better.
If Entities does not spawn Instantiate should return null or cast an exception… maybe you can check by stepping through the code with the debugger…

//this part of your code doesn't work as intended, as you see
//so you have to decide a new condition for decreasing StartTimebtwSpawn
TimebtwSpawn = StartTimebtwSpawn;
if (TimebtwSpawn > StartTimebtwSpawn)
{
    StartTimebtwSpawn -= decreaseTime;
}

My suggestion

//This provide the information what to spawn
string[] logMsg = {"Beginner", "Easy", "Moderate", "Hard", "Very Hard", "God Mode"};
void Difficutlyrating()
{
    TimebtwSpawn -= Time.deltaTime;
    if (TimebtwSpawn <= 0)
    {
        int difficutly = 0;
        GameObject[][] go = { Entities, EntitiespatEasy, EntitiespatModerate,
            EntitiespatHard, EntitiespatVeryHard, EntitiespatGodmode };

        TimebtwSpawn = StartTimebtwSpawn;
        numspawn++;
        //StartTimebtwSpawn -= decreaseTime; //you must find out when you want to do this

        if(numspawn <= 20) difficutly = 0;
        else if(numspawn <= 40) difficutly = 1;
        else if(numspawn <= 60) difficutly = 2;
        else if(numspawn <= 80) difficutly = 3;
        else if(numspawn <= 100) difficutly = 4;
        else if(numspawn > 100) difficutly = 5;

        Debug.Log(logMsg[difficutly]);
        int rand = Random.Range(0, go[difficutly].Length);
        Instantiate(go[difficutly][rand], transform.position, Quaternion.identity);
    }
}

The reason why the number is increasing (Just for knowledge) without spawning the object is this :

else
{
    TimebtwSpawn -= Time.deltaTime;
    numspawn++; // <- This line
}

Remove it in all places and the script should work fine
BUT, The code is very unnecessarily lengthy and you should follow @rh_galaxy 's method