Skip to main content
skill CX Codex

roblox-characters — Claude Code skill: respawn-safe Roblox characters

Keeps Roblox character code working across respawns, so scripts stop holding stale Humanoid and root references.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill roblox-characters -a claude-code
Open on GitHub

What roblox-characters does

The skill treats Player as the durable identity and every Character as a replaceable session with its own references, connections and animation tracks. Character-scope state gets one cleanup scope and is destroyed on removal; player-scope state survives the respawn.

Two Lua patterns ship with it. The first binds characters through CharacterAdded, checks player.Character before teardown and uses a generation counter so a deferred call cannot wipe a binding that is already current. The second loads animations through the rig's Animator, connects marker signals for gameplay timing and stops the tracks on cleanup. A rules section covers movement and rigs: don't hardcode R15 limb names when R6 is supported, and don't hand out damage authority just because a client owns its character's physics.

Physics queries, remote trust and camera logic live in other skills in the same set, so this one stays on the character lifecycle. The section on tools and accessories cuts off mid-sentence, which is worth knowing before you expect a worked equip example.

What it helps with

  • fix character scripts that break after respawn
  • drop stale Humanoid and HumanoidRootPart references
  • load AnimationTracks through Animator and stop them on cleanup
  • handle death and disconnect character connections
  • support a custom rig that has no Humanoid

Example prompts for the agent

  • My movement script dies after respawn — rewrite it around CharacterAdded with a single cleanup scope
  • Load the punch animation through Animator and fire a client effect on its marker
  • We support R6 and R15 — remove the hardcoded R15 limb names from the character code

How to install roblox-characters

1Skills CLI (Vercel)

npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill roblox-characters -a claude-code

2Manually: put the files in place

~/.claude/skills/roblox-characters/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/roblox-characters/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about roblox-characters

How do I install roblox-characters in Claude?

Run npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill roblox-characters -a claude-code. The skill lands at ~/.claude/skills/roblox-characters/SKILL.md.

What does roblox-characters do?

It covers the Roblox character lifecycle: binding through CharacterAdded and CharacterRemoving, Humanoid state and movement, R6/R15 rigs, animations, death and custom characters. The point is to never keep a character reference longer than one spawn.

Does it cover physics or networking?

No. General physics queries and constraints belong to roblox-physics, remote trust to roblox-networking, and camera logic to camera-systems.

Source text

SKILL.md · Apache-2.0
---
name: roblox-characters
description: >
  Build respawn-safe Roblox character systems around Players, CharacterAdded/CharacterRemoving,
  Humanoid, HumanoidRootPart, Animator, R6/R15 rigs, movement, animations and markers, death,
  tools, accessories, ownership, and custom characters. Use when character scripts break after
  respawn, cache stale Humanoids, control movement or velocity, load AnimationTracks, handle death,
  equip Tools, modify avatars, or support custom player rigs.
---

# Roblox characters

Treat a `Player` as the durable identity and each `Character` as a replaceable session with its own
references, connections, animation tracks, and cleanup. Targets Roblox's rolling platform APIs.

## When to use

- Use for player-character lifecycle, Humanoid state/movement, rigs, animations, tools,
  accessories, custom characters, death, or respawn defects.
- Use whenever code stores a Character/Humanoid/root reference longer than one spawn.

**When not to use:** general physics queries and constraints belong to `roblox-physics`; remote
trust belongs to `roblox-networking`; camera logic belongs to `camera-systems`.

## Workflow

1. **Inspect the character contract.** Check avatar settings, `StarterCharacter`,
   `StarterCharacterScripts`, `CharacterAutoLoads`, R6/R15 support, existing Animate/controller
   scripts, tools, tags, collision groups, and server/client ownership.
2. **Separate scopes.** Player-scope state survives respawn; character-scope state does not. Put
   character connections/tracks/resources in one cleanup scope and destroy it on removal.
3. **Bind existing and future characters.** Connect `CharacterAdded`, then bind `player.Character`
   if present. Do not assume event subscription alone sees a character that already spawned.
4. **Resolve required components defensively.** Wait with a timeout where replication warrants it;
   validate `Humanoid`, root, `Animator`, and rig assumptions. Abort if that character is no longer
   current before applying delayed work.
5. **Choose movement ownership.** Use Humanoid movement for standard avatars; use
   `AssemblyLinearVelocity`, `BasePart:ApplyImpulse()`, or a `LinearVelocity`/`AlignPosition`
   constraint only for mechanics that need physical control. Keep gameplay
   authority and network ownership implications explicit.
6. **Own animation lifecycle.** Load via the rig's `Animator`; store tracks/connections; use named
   markers for gameplay timing only with server validation; stop/disconnect on character cleanup.
7. **Verify lifecycle stress.** Spawn, die, reset, rapid-respawn, swap rig if supported, equip/drop
   tools, leave during setup, and run with at least two players when character interactions matter.

## Pattern: replaceable character scope

```lua
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local generation = 0
local connections: {RBXScriptConnection} = {}
local currentCharacter: Model? = nil

local function clearCharacter()
    generation += 1
    for _, connection in connections do connection:Disconnect() end
    table.clear(connections)
    currentCharacter = nil
end

local function bindCharacter(character: Model)
    -- Guard BEFORE teardown. A stale invocation (see the CharacterAdded/defer race below) must not
    -- clear a binding that is already current, or nothing ends up bound at all.
    if player.Character ~= character then return end
    clearCharacter()
    currentCharacter = character
    local thisGeneration = generation
    local humanoid = character:WaitForChild("Humanoid", 10)
    local root = character:WaitForChild("HumanoidRootPart", 10)
    -- Re-check after the yields: a respawn during WaitForChild bumps generation and makes this call stale.
    if not humanoid or not root or generation ~= thisGeneration then return end

    table.insert(connections, humanoid.Died:Connect(function()
        if generation ~= thisGeneration then return end
        setCharacterUiEnabled(false)
    end))
    attachCurrentCharacterSystems(character, humanoid, root)
end

player.CharacterRemoving:Connect(function(character)
    if currentCharacter == character then clearCharacter() end
end)
player.CharacterAdded:Connect(bindCharacter)
if player.Character then task.defer(bindCharacter, player.Character) end
```

Use the project's cleanup utility when one exists; do not introduce a new framework for three
connections. Server systems repeat this binding per `Player` and clear player-scope tables on
`PlayerRemoving`.

## Pattern: animation through Animator and markers

```lua
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://1234567890"
local track = animator:LoadAnimation(animation)
local markerConnection = track:GetMarkerReachedSignal("Commit"):Connect(function(parameter)
    playLocalSwingEffect(parameter) -- presentation; server still validates any hit
end)

track:Play(0.1)
-- On character teardown:
markerConnection:Disconnect()
track:Stop(0.1)
animation:Destroy()
```

For rigs without a `Humanoid`, use an `AnimationController` with an `Animator`. Do not use the
deprecated convenience path as a substitute for owning the actual Animator and track lifecycle.

## Movement and rig rules

- Do not hardcode R15 limb names if R6 is supported. Prefer attachments, tags, or a rig-type
  adapter; branch on `Humanoid.RigType` only where topology materially differs.
- `HumanoidRootPart` is the usual character assembly root, not a universal guarantee for every
  custom model. Define the custom rig contract and validate it at spawn.
- Prefer `Humanoid:Move()`/standard controls for ordinary avatar locomotion. Directly changing
  `AssemblyLinearVelocity` is an instantaneous physical action; use forces/constraints or impulses
  when continuous or instantaneous physics is the real intent.
- To rebind movement/jump or add actions like sprint, prefer the Input Action System
  (`InputContext`/`InputAction`/`InputBinding`, defined at edit time and cross-device)
  over hooking `UserInputService` directly. Default player and character control scripts
  run on this system when `Workspace.PlayerScriptsUseInputActionSystem` is enabled,
  exposing default `PlayerScripts` contexts; give your own `InputContext` a higher
  `Priority` (and `Sink`) to take precedence over the default bindings. See the
  `roblox-ui` input and navigation reference for the UI-focus side of this.
- Check whether the place opted into the Character Controller Library (beta; Avatar Settings ⟩
  Movement ⟩ Abilities) or a `ControllerManager` setup. Those replace `HumanoidStateType`-driven
  logic with abilities/controllers, so extend that system instead of layering Humanoid state
  changes on top of it.
- Never grant damage or movement authority because a client owns its character physics. Validate
  cross-player consequences on the server.
- Tools move between Backpack and Character during equip; listen to lifecycle/state rather than
  assuming one fixed parent. Modify accessories/appearance through current character APIs and
  preserve an up-to-date applied `HumanoidDescription` when editing avatar appearance.

## Common failures

| Symptom | Likely cause | Remedy |
|---|---|---|
| works once, breaks after reset | cached character/Humanoid/root | rebuild per `CharacterAdded`; clear on removal |
| callbacks fire twice after deaths | old character connections survived | character-scoped cleanup and generation/current checks |
| delayed load edits wrong rig | async work outlived spawn | compare current Character/generation after every yield |
| animation visible only locally or not at all | wrong Animator/context/asset ownership | inspect rig Animator, execution side, permissions, and replication |
| hit marker awards impossible hit | animation marker trusted as authority | use marker for timing/presentation; server validates combat state |
| R6/custom rig errors | R15 names assumed | define rig contract; attachments/adapter; test each supported rig |
| tool disappears from system | fixed Backpack/Character parent assumed | handle equip/unequip ancestry and character replacement |
| custom force fights Humanoid | two controllers own motion | choose one movement authority per state and restore cleanly |

## Resources

- Read `references/lifecycle-and-animation.md` for server binding, death vs removal, rig and
  animation verification, custom characters, and the lifecycle stress matrix.

## Related skills

- `roblox-physics` — forces, constraints, assemblies, collision, and network ownership.
- `roblox-networking` — server validation of character actions and stale requests.
- `input-systems` — action mapping and responsive movement intent.
- `camera-systems` — camera behavior following replaceable characters.

## Primary references

- `https://create.roblox.com/docs/characters`
- `https://create.roblox.com/docs/animation/using`
- `https://create.roblox.com/docs/characters/appearance`
- `https://create.roblox.com/docs/characters/character-controller-library`

© gamedev-skills · Apache-2.0 · gamedev-skills/awesome-gamedev-agent-skills

Similar skills

Everything for Game dev and 3D: Unity, Unreal, Godot, Blender →

From the same set77

ai-behavior-trees-utility-ai Builds a production behavior-tree runtime and Utility AI decision system for game NPCs. Best for moving beyond simple FSM logic in Unity or Godot projects. CX Codex +1 4,900installs roblox-ui A skill for building Roblox interfaces: ScreenGui lifecycle, responsive UDim2 layouts, gamepad and touch input. Useful when UI clips or resets on respawn. CX Codex +1 3,800installs roblox-studio-workflow A workflow skill for editing existing Roblox Studio projects, from inspecting the project tree to Studio testing and removing temporary test objects. CX Codex +1 3,700installs roblox-networking A skill for designing and hardening Roblox client/server networking: RemoteEvent, RemoteFunction, UnreliableRemoteEvent, validation and rate limits. CX Codex +1 3,500installs roblox-physics A skill for Roblox physics work: assemblies, constraints, collision groups, raycasts and network ownership. Useful when .Touched lies or a mechanism jitters. CX Codex +1 3,500installs godot-gdscript-headless-testing Runs GDScript test suites in Godot 4 via godot --headless and returns real process exit codes. It helps verify game logic in CI pipelines without launching the editor GUI. CX Codex +1 3,100installs ebitengine-game An agent skill for building, debugging and packaging playable 2D games in Go with Ebitengine. Useful when you want a finished loop, not a nice screenshot. CX Codex +1 659installs defold-core Helps build and debug Defold games in Lua: configures game.project, manages collections, wires message passing, and checks builds with Bob. CX Codex +1 623installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor