CyberMax
CyberMax › Answers

Roblox pet system: make pets follow the player smoothly

Updated 2026-10-17 · Roblox and game developers · by CyberMax

Short answer

Move pets on the client every frame: compute a target position behind the player's HumanoidRootPart for each pet (spread in an arc), add a small sine-wave bob, and lerp each pet's CFrame toward its target with an alpha based on deltaTime so the speed is the same at any frame rate. Ownership and equipping stay on the server.

Copy-paste code

StarterPlayerScripts/PetFollow.client.lua (pets in workspace.Pets[player.Name])

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer

local RADIUS, SPREAD = 5, math.rad(140)

RunService.RenderStepped:Connect(function(dt)
	local char = player.Character
	local root = char and char:FindFirstChild("HumanoidRootPart")
	local folder = workspace:FindFirstChild("Pets") and workspace.Pets:FindFirstChild(player.Name)
	if not (root and folder) then return end
	local pets = folder:GetChildren()
	local alpha = 1 - math.exp(-10 * dt) -- frame-rate independent smoothing
	for i, pet in pets do
		local t = #pets == 1 and 0.5 or (i - 1) / (#pets - 1)
		local angle = -SPREAD / 2 + SPREAD * t
		local offset = Vector3.new(math.sin(angle) * RADIUS, 1.5 + math.sin(os.clock() * 2 + i) * 0.3, math.cos(angle) * RADIUS)
		local target = root.CFrame * CFrame.new(offset)
		pet:PivotTo(pet:GetPivot():Lerp(target, alpha))
	end
end)

Good to know

Anchor the pet models and turn off CanCollide, so physics never fights the script.

Other players see your pets move only if each client runs the same script for every player's folder, or if the server moves them; client-side for everyone looks smoothest.

Hatchwren Pet & Egg System: Pets and eggs for your simulator, done right

from $12

Hatchwren is the complete pet and egg system: eggs with true odds, luck and pity; triple hatch and Robux eggs; an inventory with equip slots and locks; Golden/Rainbow fusing; and pets that follow every player. Its free sampler includes the Formation module.

Secure checkout · 14-day fix-or-refund if it doesn't work as described (terms)

Questions

Why do my pets lag behind?

A fixed lerp alpha like 0.1 depends on frame rate. Use 1 - math.exp(-k * dt) as above.

How do pets face the player's direction?

The target uses root.CFrame, so they turn with the player.

Free: the Roblox Starter Kit

7 free Luau modules (damage, pets, shop formatting, admin audit log, tycoon guards and more) plus 3 free calculators, then 5 short emails with the scripting fixes we see go wrong most often.

You get one email to confirm first. Then the kit, and 5 short emails over two weeks. One-click unsubscribe in every email; we never share your address.

Related answers

Roblox egg hatching script: weighted random pets with real oddsServer-side egg hatching with weighted random rolls, shown odds that match the code, and a charge-once rule soA Roblox DataStore save script that never wipes player dataCopy-paste Luau for loading and saving player data with DataStoreService: retries, UpdateAsync, BindToClose an