Your First Character
What is a Character?
Writing a Character
-- "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,
}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 exampleUsing a Character
Summary
Last updated