Making an object a child through scripting

So I’ve managed to make a moving platform for my 2D game, but sadly my character slides off the platform as it moves. I’ve tried to increase the friction between my character’s feet and the platform itself, but it seems to make no difference.

Here’s a video demonstrating the problem:

I figured out a way to make this work very well, and that is to just make my character a child of the platform. I just have no idea how to make this a dynamic thing. I want the character to become a child when she is grounded, and I want her to split off when she is not grounded on the platform.

If anyone is curious what my controller script looks like here it is:

    using UnityEngine;
    using System.Collections;
     
    public class TestAliceControllerScript : MonoBehaviour
    {
            public float maxSpeed = 10f;
            bool facingRight = true;
            Animator anim;
     
            bool grounded = false;
            public Transform groundCheck;
            float groundRadius = 0.2f;
            public LayerMask whatIsGround;
            public float jumpForce = 700;
     
            void Start ()
            {
                    anim = GetComponent<Animator> ();
            }
     
            void FixedUpdate ()
            {
                    grounded = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
                    anim.SetBool ("Ground", grounded);
     
                    anim.SetFloat ("vSpeed", rigidbody2D.velocity.y);
     
     
     
                    float move = Input.GetAxis ("Horizontal");
     
                    anim.SetFloat ("Speed", Mathf.Abs (move));
     
                    rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);
     
                    if (move > 0  !facingRight)
                            Flip ();
                    else if (move < 0  facingRight)
                            Flip ();
            }
            void Update ()
            {
                    if (grounded  Input.GetButtonDown ("Jump")) {
                            rigidbody2D.AddForce (new Vector2 (0, jumpForce));
                    rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, 0);
                    rigidbody2D.AddForce(new Vector2(0f, jumpForce));
                    }              
            }
            void Flip ()
            {
                    facingRight = !facingRight;
                    Vector3 theScale = transform.localScale;
                    theScale.x *= -1;
                    transform.localScale = theScale;
            }
    }

Any help my friends?

//pseudo code
if isGrouded and isOnPlatform than
    meCharacter.transform.parant = mePlatform.transform;
if not than
    meCharacter.transform.parant = null;