My player changes it original scale when on a moving platform..please help.THanks

hello guys, so i am working on a school project on unity and i am having a problem with my player…i have lot of moving platform on my project and i need my player to be to attached on the moving platform but the problem is that whenever my player is on the platform my player changes it orginal scale to some random scale…please i need help…i have read some answers related to to my question but up till now non of it works …please i need help fast…THANKS

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

public class AttachPlay : MonoBehaviour
{
   
    public GameObject Player;

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject == Player)
        {
            Debug.Log("touch");
            Player.transform.parent = transform;

        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject == Player)
        {
            Player.transform.parent = null;
            Player.transform.localScale = DefaultScale.defaultScale;
        }
    }
    
}

original code from @ultimate1999

The solution:

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

public class AttachPlay : MonoBehaviour
{
   
    public GameObject Player;

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject == Player)
        {
            Debug.Log("touch");
            Player.transform.parent.parent = transform;

        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject == Player)
        {
            Player.transform.parent.parent = null;
            Player.transform.localScale = DefaultScale.defaultScale;
        }
    }
    
}

On Player.transform.parent you need to put another .parent, so the code look like Player.transform.parent.parent

The parent’s scale influences the children as well. When it is parented, divide the player’s scale by the platform’s scale.

For example, if player is scaled (1,1,1) and the platform is (0.7, 0.2, 0.7) the player will need to be scaled to (1.4286, 5, 1.4286) to keep it’s correct size when parented. Of course when it is unparented, revert the scale back.