本文へスキップ
Skillpedia
一般的なプログラミング6.6k · #13836

roblox-characters

できること

リスポーン、死亡、そのほかの変化の後も動き続けるRobloxのキャラクターのスクリプトを書く方法を示します。Robloxの体験でプレイヤーのキャラクターを作る開発者向けです。

使う場面

  • ✓プレイヤーがリスポーンした後に、Robloxのキャラクターのスクリプトが壊れるとき。
  • ✓キャラクターの移動を制御したり、アニメーションを再生したり、死亡を扱ったりする必要があるとき。
  • ✓キャラクターにツールを持たせたり、アクセサリーを変えたりしたいとき。

スキルのリンク

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/other-engines/roblox-characters/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/other-engines/roblox-characters/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“Robloxのキャラクターの速さが、リスポーンの後に元に戻ってしまいます。スクリプトをどう直せばよいですか。”

毎週5つの新しいスキル。1分で読めます。

仕組み

スキルは、プレイヤーはプレイ中ずっと同じだが、キャラクターはスポーンのたびに作られる一時的なものであることを説明します。そのため、エージェントは長く残るデータと、キャラクターごとの接続を分け、後片付けをします。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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

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

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:De
よくある質問

Robloxのプレイヤーとキャラクターの違いは何ですか?

プレイヤーはプレイ中ずっと同じで、キャラクターはスポーンのたびに作られる新しい体です。

R6とR15のリグも扱いますか?

はい。アニメーションとキャラクターのパーツを設定するとき、両方のリグの種類を扱います。

物理やリモートも扱いますか?

それらは別のRobloxのスキルで、一方は物理、もう一方はネットワークを扱います。

詳細

作者による元の説明

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.

repo: gamedev-skills/awesome-gamedev-agent-skills

人気

GitHubのスター
6.6k
ランキング
#13836
ライセンス
Apache-2.0
更新日
2026/10/28

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル