How to make the same effect when you walk with your pets?

Hey guys!

I’m wondering on how to make the same effect as a lot of Roblox Simulator Games.

Here is what I’m looking for (sorry for bad quality video):
robloxapp-20201110-1159057.wmv (2.2 MB)

This video comes from the game Tapping Legends: Tapping Legends - Roblox

I would like to have the same effect in my Roblox game, when you walk your pets look at where you are facing and when you’re idle your pets are looking you.

I think I have to use HumanoidStates.

But it is not the problem to detect when the player is idle or when the player run.

I think they user AlignPositions and AlignOrientations for their pets.
So the problem I have is to know how to turn the pets to the player when he is Idle.

Someone can help me pls?

You can check if the player’s character’s humanoid’s StateType using Humanoid:GetState(), if the humanoid state is Idle then make the pets look towards the player, if not, make them face the same direction as the player’s humanoid root part. Read more about HumanoidStateType here.

1 Like

Yeah I think it is the good way to detect what the player is doing.

But the problem is I don’t know how to turn the pet to the player…

If you’re using alignorientation and alignposition, you could have one attachment parented to a part in the pet (that part’s lookvector should point to where the pet is facing). The other attachment could be parented to terrain. Then, every frame, change the cframe of the attachment that is parented to terrain. You’ll need to add some things to this yourself, but maybe it’ll help.

local RunService = game:GetService("RunService")

local petPart = -- the part that will have an attachment
local characterPart = -- maybe head?
local hrp = -- humanoidrootpart

local alignPos = -- the alignPosition
local alignOri = -- the alignOrientation

local attach0, attach1 = Instance.new("Attachment"), Instance.new("Attachment")
alignPos.Attachment0, alignPos.Attachment1 = attach0, attach1
attach0.Parent, attach1.Parent = petPart, workspace.Terrain

alignPos.Parent, alignOri.Parent = petPart, petPart


local function update()
    local pos = -- the position where the pet should go to
    local dir
    if --[[idle check]] then
        dir = characterPart.Position-petPart.Position
    else dir = hrp.LookVector
    end
    attach1.CFrame = CFrame.LookAt(pos, pos+dir)
end

RunService.Heartbeat:Connect(update)

I red your code and I like it! I’ll try that and I will give you my feedback! Thank you!