My tag isn't changing

Here’s the code:

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using JetBrains.Annotations;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;

public class ColorScript : MonoBehaviour
{
    public Color[] color = new Color[5];
    public int puyoColor = 4;
    public bool pieceRotate = true;
    public bool pieceFall = false;
    public PuyoScript puyoScript;
    public GameObject puyoSpawn;
    public SpawnPuyoScript spawnPuyoScript;
    public Customization customization;
    int colorCount = 1;
    List<int> colors = new List<int>();
    public GameObject puyo1;
    public int randomColor;
    public bool randomize;
    public bool tagChange;
    void Start()
    {
        if (puyoColor == 3)
            this.gameObject.GetComponent<SpriteRenderer>().color = color[Random.Range(0, 3)];

        if (puyoColor == 4)
            this.gameObject.GetComponent<SpriteRenderer>().color = color[Random.Range(0, 4)];

        if (puyoColor == 5)
            this.gameObject.GetComponent<SpriteRenderer>().color = color[Random.Range(0, 5)];

        randomColor = Random.Range(1, 6);
    }
    void Update()
    {
        if (pieceRotate == true)
            if (Input.GetKeyDown(KeyCode.X))
            {
                transform.eulerAngles += new UnityEngine.Vector3(0, 0, 90);
            }

        if (pieceFall == true)
        {
            transform.position -= new UnityEngine.Vector3(0, 0.001f, 0);
        }

        if (pieceFall == false)
        {
            transform.position -= new UnityEngine.Vector3(0, 0, 0);
        }

        if (tagChange == true)
        {
            pieceRotate = false;
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.layer == 2)
        {
            pieceRotate = true;
            pieceFall = false;
        }

        if (other.gameObject.layer == 3)
        {
            pieceRotate = true;
            pieceFall = false;
        }

        if (other.gameObject.layer == 4)
        {
            pieceRotate = false;
            pieceFall = false;
        }

        if (other.gameObject.layer == 5)
        {
            pieceRotate = false;
            pieceFall = false;
        }

        if (other.gameObject.layer == 6)
        {
            pieceRotate = false;
            pieceFall = false;
        }

        if (other.gameObject.layer == 7)
        {
            pieceRotate = false;
            pieceFall = false;
            tagChange = true;
            this.gameObject.tag = "Other Falling 2";
        }
        
        if (other.gameObject.layer != 7)
        {
            pieceRotate = true;
            pieceFall = false;
        }

        if (other.gameObject.tag == "Falling")
        {
            this.gameObject.tag = "Not Falling";
            pieceFall = true;
        }

        if (other.gameObject.tag == "Not Falling")
        {
            this.gameObject.tag = "Not Falling";
            pieceFall = false;
        }

        if (other.gameObject.tag == "Other Falling")
        {
            this.gameObject.tag = "Falling";
            pieceFall = false;
        }

        if (other.gameObject.tag == "Other Falling 2")
        if (this.gameObject.tag == "Not Falling")
        {
            tagChange = true;
            this.gameObject.tag = "Other Falling";
            pieceRotate = false;
        }

        if (this.gameObject.tag == "Other Falling")
        {
            pieceRotate = false;
        }

        if (this.gameObject.tag == "Not Falling")
        {
            pieceFall = false;
        }

        if (this.gameObject.tag == "Other Falling 2")
        {
            other.gameObject.tag = "Other Falling";
            Debug.Log("Pain");
        }
    }
    void OnTriggerStay2D (Collider2D other)
    {
        if (this.gameObject.tag == "Not Falling")
        {
            other.gameObject.tag = "Other Falling";
            Debug.Log("Pain");
        }
    }
}`Preformatted text`

And here’s how to communicate technical questions to strangers:

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, log output, variable values, and especially any errors you see
  • links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)

The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?

If you have no idea what is happening, fix that first. Here’s how:

Time to start debugging!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

The code has many issues, e.g you set the tag "Other Falling 2 and then use an if with it, resseting it to "Other Falling’’ few lines below.

Try to use ‘else if’ than just ‘if’ to avoid this.

Also there is an if without brackets to do anything, not sure what this does.

if (other.gameObject.tag == "Other Falling 2")
        if (this.gameObject.tag == "Not Falling")
        {
            tagChange = true;
            this.gameObject.tag = "Other Falling";
            pieceRotate = false;
        }

Hm, I just realized this is the same poster from June 12, 2024:

C’mon OP, you’ve been struggling with these simple things for over a year now.

Please take some time to do some learning before trying to tackle something like a Tetris game; Junior Programmer Pathway - Unity Learn

It’s not as simple as you think it is and you will continue to struggle if you don’t listen to anyone.

The problem I had was that either clones or child objects can’t be detected via collision. Is there anyway I can make it so that they can?