---
tags:
    - "Transform"
    - "Reparent"
    - "Hierarchy"
---

# Set Transform Parent

[Transform](../index.md) / [Hierarchy](index.md) / **Set Transform Parent**

## Description

Changes the hierarchy by setting the parent of a Transform

## Parameters

| Name | Description |
| :--- | :---------- |
| Transform | The Transform to change its parent |
| Parent | Which is the new parent of the Transform |

## Code

```cs
using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Set Transform Parent")]
    [Category("Transform/Hierarchy/Set Parent")]
    [Description("Changes the hierarchy by setting the parent of a Transform")]

    [Image(typeof(IconHanger), ColorTheme.Type.Lime)]
    [Keywords("Transform", "Reparent", "Hierarchy")]

    [Parameter("Transform", "The Transform to change its parent")]
    [Parameter("Parent", "Which is the new parent of the Transform")]

    [Serializable]
    public class InstructionTransformSetParent : Instruction
    {
        [SerializeField] private GetGameObject m_Transform = new GetGameObject();
        [SerializeField] private GetGameObject m_Parent = new GetGameObject();

        protected override string GetTitle(GameObject source)
        {
            string member = TextUtils.ThemeAsKeyword("Parent");
            return $"{this.m_Transform} {member} = {this.m_Parent}";
        }

        protected override Awaitable Run(Args args)
        {
            Transform component = this.m_Transform.Get<Transform>(args);
            if (component == null) return Done;

            component.parent = this.m_Parent.Get<Transform>(args);
            return Done;
        }
    }
}
```

