# Your First Character

Characters is another name for a _component_, which you can attach to an instance by giving it a tag. It is essentially the same as creating a class and binding it to a CollectionService tag.

{% hint style="info" %}
**YOU WILL LEARN HOW TO**

* Write your own Character
* Use your Character's lifecycles
* Set your Character's priority
{% endhint %}

***

## What is a Character?

A _Character_ is synonymous with a component or an instance-attached class. Instead of creating a metatable and then defining an instance for it, Characters simplify this process by automatically assigning themselves to a given tag. You can then treat it as if it was a regular luau class by adding functions to the Character.

***

## Writing a Character

Every book needs its own characters! Here is how you might write your own Character for your workflow:

{% tabs %}
{% tab title="Method 1" %}
{% code title="ServerScriptService.server_book.characters.example.luau" overflow="wrap" lineNumbers="true" %}
```lua
-- "init" is a lifecycle hook that always runs first!
local function init(self) -- "self" passes an instance attached to the tag.
    print("Character is attached to " .. self.instance:GetFullName())
end

-- "destroy" is a lifecycle hook that runs on the instance being removed.
local function destroy(self)
    print("Character " .. self.instance:GetFullName() .. " has been destroyed!")
end

return {
    tag = "Example_Tag", -- This Character now binds to any instance with this tag.
    init = init,
    destroy = destroy,
}
```
{% endcode %}
{% endtab %}

{% tab title="Method 2" %}
{% code title="ServerScriptService.server_book.characters.example.luau" overflow="wrap" lineNumbers="true" %}
```lua
local example = {
    tag = "Example_Tag", -- This Character now binds to any instance with this tag.
}

-- "init" is a lifecycle hook that always runs first!
function example:init()
    print("Character is attached to " .. self.instance:GetFullName())
end

-- "destroy" is a lifecycle hook that runs on the instance being removed.
function example:destroy() -- Cleanup function.
    print("Character " .. self.instance:GetFullName() .. " has been destroyed!")
end

return example
```
{% endcode %}
{% endtab %}
{% endtabs %}

If you did everything correctly, this should now print the full names of any instance that has the <kbd>Example\_Tag</kbd> tag.

***

## Using a Character

{% hint style="warning" %}
**WARNING** ― As of right now, getting a Character from its instance is not possible with Quill. This is, however, an intended feature of Quill and will most likely come out in version _0.2.0-alpha_.
{% endhint %}

***

## Summary

* **Characters** are components that provide functions to tagged instances.
* **Lifecycle hooks** are automatically called on runtime, allowing Characters to run automatically and independently.
