transform global, strange behaviour,transform global and local

public void deAtach()
{

    GameObject player = GameObject.Find("Player");
    Vector3 worldPos = player.gameObject.transform.position;

    player.transform.parent = null;
    player.transform.rotation = Quaternion.identity;
    player.transform.position = worldPos;

}

i have this piece of code, when called deAtach player from his actual parent and stay in the same world place, when i debug worldPos the values are correct with global position expected, but when applied to player the values are the same from localPosition,public void deAtach()
{

    GameObject player = GameObject.Find("Player");
    Vector3 worldPos = player.gameObject.transform.position;

    player.transform.parent = null;
    player.transform.rotation = Quaternion.identity;
    player.transform.position = worldPos;

}

i have this piece of code, i call to deatach player from an object and preserve his position when he was parented but when i apply worldPos its like applying in local position but when i debug worldPos to see the values, they correspond with global

it is unclear what the question is. I’m guessing you are asking why the worldposition and localposition are the same?

After the player has no Parent, its is then effectively “parented” directly to the scene, its local position will then always match its world position as it’s parent is the world itself.