I want the pets that are following my player around to be animated with a little โhopโ when moving, similar to Pet Simulator x/99.
I have set all pets up correctly to be animated, but the animations are not playing when the pet is moving.
Here is the part of code that handles that:
humanoid.WalkSpeed = 10
-- ๐งช Debug
print("Children of petModel:", petModel:GetChildren())
-- ๐ Walking animation setup
if petModel:FindFirstChild("Walks") then
print("โ
Walks tag found โ Setting up animation")
local animator = humanoid:FindFirstChildOfClass("Animator")
if not animator then
animator = Instance.new("Animator")
animator.Name = "Animator"
animator.Parent = humanoid
print("๐งฑ Animator created and parented to humanoid")
end
local walkAnim = Instance.new("Animation")
walkAnim.AnimationId = "rbxassetid://109577155834640" -- Replace this!
walkAnim.Parent = petModel
local walkTrack = animator:LoadAnimation(walkAnim)
walkTrack.Priority = Enum.AnimationPriority.Movement
-- Optional: ensure humanoid can animate
humanoid:ChangeState(Enum.HumanoidStateType.Running)
local lastPos = petModel.PrimaryPart.Position
game:GetService("RunService").Heartbeat:Connect(function()
if not petModel:IsDescendantOf(character) then return end
local currentPos = petModel.PrimaryPart.Position
local distance = (currentPos - lastPos).Magnitude
if distance > 0.05 then
if not walkTrack.IsPlaying then
walkTrack:Play()
end
else
if walkTrack.IsPlaying then
walkTrack:Stop()
end
end
lastPos = currentPos
end)
end
end
Iโve tried a few variations of the code but nothing seems to get them animated