This guide shows you how to make a rig (like a character model) follow you in Roblox Studio. By the end, you’ll have a rig that walks or flies toward your player character, which is great for NPCs, companions, or simple enemy AI. You’ll need a basic understanding of the Explorer window and the ability to insert a rig from the Toolbox.
What You’ll Need
- Roblox Studio installed and a place open (any template works).
- A rig model. You can use the built-in R15 or R6 rigs from the Toolbox (search “R15” or “R6” in the Toolbox, or use the Avatar tab to insert one).
- Basic knowledge of where the Explorer and Properties windows are (View tab > Explorer and Properties).
Step-by-Step
- Insert a rig. Go to the Toolbox (View tab > Toolbox), search for a rig like “R15 Rig” or “R6 Rig”, and click to insert it into your place. Alternatively, use the Avatar tab > Rig Builder to create one. The rig should appear in the Workspace.
- Rename the rig. In the Explorer, find the rig model (it might be named “R15” or similar). Select it, then in the Properties window, change its Name to something like “FollowerRig”. This makes scripting easier.
- Add a Script. Right-click on the rig model in the Explorer, select “Insert Object”, and then choose “Script”. This creates a new script inside the rig. Double-click the script to open the code editor.
- Write the follow script. Replace the default code with the following:
local rig = script.Parent local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = rig:FindFirstChildOfClass("Humanoid") local rootPart = rig:FindFirstChild("HumanoidRootPart") or rig:FindFirstChild("Torso") local speed = 16 -- adjust as needed while true do wait(0.1) if not character or not character:FindFirstChild("HumanoidRootPart") then character = player.Character or player.CharacterAdded:Wait() end local target = character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("Torso") if target and rootPart and humanoid then local direction = (target.Position - rootPart.Position).unit rootPart.CFrame = rootPart.CFrame + direction * speed * 0.1 humanoid:MoveTo(target.Position) end endNote: This script makes the rig move toward the player’s character. It works in both Studio Test mode and when published, but only for the local player (the one running the game). For a server-wide effect, you’d need a server script, but this is fine for testing.
- Test the script. Click the “Play” button (or press F5) to test your game. Your character will spawn, and the rig should start moving toward you. If the rig is far away, it will walk toward you. If it gets stuck, see Troubleshooting below.
- Adjust speed and behavior. Change the
speedvariable in the script to make the rig faster or slower. You can also modify the script to make it fly by setting the rootPart’s CFrame directly (instead of using MoveTo).
Common Mistakes
- Using a Server Script instead of a Local Script. The script we wrote uses
game.Players.LocalPlayer, which only works in a Local Script. If you insert a Script (server), it won’t work because LocalPlayer is nil on the server. Always insert a “Local Script” (right-click > Insert Object > LocalScript) for this specific code. - Wrong part names. R15 rigs use “HumanoidRootPart”, but R6 rigs use “Torso”. The script checks both, but if your rig has a different name (like “RootPart”), it won’t find it. Check the rig’s parts in Explorer.
- Not waiting for the character. If the player’s character isn’t loaded when the script runs,
player.Charactermight be nil. The script handles this withCharacterAdded:Wait(), but if you test without a character (like in Solo mode), it may error. Always test in Play mode. - Rig not anchored. If the rig is anchored (Anchored property set to true), it won’t move. Select the rig’s parts and ensure Anchored is false (or uncheck it in Properties).
Tips
- Make the rig face you. To make the rig rotate to face the player, add this line inside the loop:
rootPart.CFrame = CFrame.lookAt(rootPart.Position, target.Position)before moving. - Add a distance check. To avoid jittering when close, add an if statement to stop moving when the distance is less than, say, 5 studs:
if (target.Position - rootPart.Position).magnitude > 5 then. - Use Humanoid:MoveTo for pathfinding. The script uses both CFrame movement and MoveTo. MoveTo uses Roblox’s pathfinding, which can navigate around obstacles. For better results, rely more on MoveTo and set the Humanoid’s WalkSpeed property.
- Make it a companion. You can add a dialogue or interaction by using ProximityPrompt or ClickDetector, but that’s beyond this guide.
Troubleshooting
- Rig doesn’t move at all. Check if the script is a LocalScript (not a Script). Also ensure the rig is not anchored. In the Explorer, select the rig, then in Properties, look for “Anchored” – set it to false for all parts (or uncheck). If it’s a model, you can select all parts by clicking the model and then in Properties, uncheck Anchored.
- Rig moves but jitters or shakes. This often happens when the CFrame movement and MoveTo fight each other. Try removing the CFrame line and only using
humanoid:MoveTo(target.Position). Also increase the wait time to 0.2 to smooth it out. - Rig gets stuck on walls. MoveTo uses pathfinding, but if the rig is too large or the path is blocked, it may get stuck. Try increasing the speed or using a smaller rig. You can also add a simple raycast to detect obstacles, but that’s advanced.
- Script errors in output. Open the Output window (View > Output) to see errors. Common ones: “LocalPlayer is not valid” (means you used a Server Script), or “HumanoidRootPart is not a valid member” (means the rig uses a different part name). Fix accordingly.
- Rig follows but only in Studio, not in published game. The script uses LocalPlayer, which works in Studio Test mode. In a published game, it will only work for the player who owns the rig (if it’s a local script). For multiplayer, you need a server script with a different approach (e.g., using a leaderboard or a value to track the player). For now, this guide is for local testing.
Frequently Asked Questions
Can I make the rig follow any player, not just me?
Yes, but you need a server script and a way to choose a target. For example, you could use a StringValue to store the target player’s name, and the server script would find that player’s character. This is more advanced.
How do I make the rig fly instead of walk?
Replace the humanoid:MoveTo() line with just the CFrame movement, and set the Humanoid’s state to “Freefall” or use a BodyVelocity. Simpler: set the Humanoid’s WalkSpeed to a high value and use the CFrame line only.
Why does the rig stop following when I die?
Because the script references the character, and when you die, the character is destroyed. The script waits for a new character via CharacterAdded:Wait(), but if the rig is destroyed or reset, it may not work. You can add a reset function to re-run the script.
Can I use this with a custom rig from Blender?
Yes, as long as the rig has a Humanoid and a root part (like HumanoidRootPart or Torso). You might need to rename parts to match the script.
How do I make the rig follow at a certain distance?
Add a distance check in the loop. For example, only move if the distance is greater than 10 studs, and stop when closer. This prevents the rig from bumping into you.
Is this script safe to use in a published game?
It works, but since it’s a LocalScript, it only affects the local player’s client. For a multiplayer experience, you’d want a server script to replicate movement to all players. For a single-player experience, it’s fine.