---
tags:
    - "Delete"
    - "Destroy"
---

# Remove Component

[Game Object](../index.md) / [Component](index.md) / **Remove Component**

## Description

Removes an existing component from the specified Game Object

## Parameters

| Name | Description |
| :--- | :---------- |
| Game Object | The game object reference |
| Component | The type of component to remove |

## Code

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

namespace VisualScript.Runtime
{
    [Title("Remove Component")]
    [Image(typeof(IconCubeOutline), ColorTheme.Type.TextLight, typeof(BadgeMinus))]
    
    [Description("Removes an existing component from the specified Game Object")]
    [Category("Game Object/Component/Remove Component")]
    
    [Parameter("Game Object", "The game object reference")]
    [Parameter("Component", "The type of component to remove")]
    
    [Keywords("Delete", "Destroy")]
    
    [Serializable]
    public class InstructionCoreGameObjectRemoveComponent : Instruction
    {
        [SerializeField] private GetGameObject m_GameObject = new GetGameObject();

        [SerializeField] private TypeReferenceComponent m_Component = new TypeReferenceComponent();

        protected override string GetTitle(GameObject source)
        {
            string component = TextUtils.ThemeAsConstant(this.m_Component.ToString());
            return $"Remove {component} from {this.m_GameObject}";
        }

        protected override Awaitable Run(Args args)
        {
            GameObject gameObject = this.m_GameObject.Get(args);
            if (gameObject != null)
            {
                Component component = gameObject.Get(this.m_Component.Type);
                UnityEngine.Object.Destroy(component);
            }
            
            return Done;
        }
    }
}
```

