Script making prefab go invisible?

Hello!
Before anything, I considered posting this on the prefabs section, but I believe that this is more of a scripting problem, so it would be more appropriate to post it here. Also this post is regarding 2D, if that helps.

So I have created two seperate codes, one to instantiate the ground prefab and one to instantiate obstacle prefabs. However the obstacles are invisible and their box colliders are still functional so the player can’t see the obstacles but they are still there. After some experimenting I have found that the code is porbably causing them to go invisible, as I tested it with the ground prefab. Here are the two codes side by side:

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

public class GroundRecycler : MonoBehaviour
{

    private const float PLAYER_DISTANCE_UNTIL_END = 14f;

    public Vector3 lastEndPosition;

    [SerializeField] private Transform ground;
    [SerializeField] private Transform player;
    void Awake()
    {
        lastEndPosition = ground.Find("GroundSpawn").position;
    }
    private void Update()
    {
        if (Vector3.Distance(player.position, lastEndPosition) < PLAYER_DISTANCE_UNTIL_END)
        {
            SpawnLevelPart();
        }
    }
    private void SpawnLevelPart()
    {
        Transform lastLevelPartTransform = SpawnLevelPart(lastEndPosition);
        lastEndPosition = lastLevelPartTransform.Find("GroundSpawn").position;
    }

    private Transform SpawnLevelPart(Vector3 spawnPosition)
    {
        Transform levelPartTransform = Instantiate(ground, spawnPosition, Quaternion.identity);
        return levelPartTransform;
    }


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

public class ObstacleSpawn : MonoBehaviour
{
    public float LastFirst;

    int rNum;
    float nSpawn;
   

    [SerializeField] private Transform obsSpawn;

   
    public GameObject[] Obstacle;

    void SpawnObstacle()
    {
        Instantiate(Obstacle[rNum], obsSpawn.position, Quaternion.identity);
    }

    void Update()
    {
        LastFirst = Random.Range(2f, 5f);
        rNum = Random.Range(0, 6);
        Debug.Log(nSpawn);
        Debug.Log(rNum);
        nSpawn += Time.deltaTime;
        if(nSpawn >= LastFirst)
        {
            SpawnObstacle();
            nSpawn = 0;
        }
    }
}

I am still relatively new, but I believe the Instantiate function has something to do with this, as it is the one that spawns the ground and obstacles. Thanks.

Nothing in those scripts sets anything invisible, so probably you have disabled the MeshRenderer component on your Obstacle prefab or you are using some invisible material.
Other than that it seems you are instantiating the obstacles at the same position maybe thats the issue, can’t say without knowing your overall setup.