#Can someone please help me. The dog doesnt look in my direction when I am walking with leash but he

1 messages · Page 1 of 1 (latest)

limber bobcat
#

continues to stare in his original direction:

local Dog = script.Parent
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

-- Check if player is moving
local function isPlayerMoving(character)
local humanoid = character:FindFirstChild("Humanoid")
if not humanoid then return false end

return humanoid.MoveDirection.Magnitude > 0.1

end

-- Make dog face player (keeps upright)
local function makeDogFacePlayer(character)
local dogHRP = Dog:FindFirstChild("HumanoidRootPart")
local playerHRP = character:FindFirstChild("HumanoidRootPart")

if dogHRP and playerHRP then
    -- Keep same Y level so dog doesn't tilt
    local lookPosition = Vector3.new(
        playerHRP.Position.X,
        dogHRP.Position.Y,
        playerHRP.Position.Z
    )

    local targetCFrame = CFrame.new(dogHRP.Position, lookPosition)
    dogHRP.CFrame = dogHRP.CFrame:Lerp(targetCFrame, 0.3)
end

end

RunService.Heartbeat:Connect(function()
local leashAttachment = Dog:FindFirstChild("Leash_Attachment_Dog")
if not leashAttachment then return end

local rope = leashAttachment:FindFirstChild("RopeConstraint")
if not rope or not rope.Attachment1 then return end

local playerHRP = rope.Attachment1.Parent
if not playerHRP or playerHRP.Name ~= "HumanoidRootPart" then return end

local character = playerHRP.Parent
local player = Players:GetPlayerFromCharacter(character)
if not player then return end

local currentlyMoving = isPlayerMoving(character)

-- If player is NOT moving, keep facing them
if not currentlyMoving then
    makeDogFacePlayer(character)
end

end)

cedar junco
#
PrimaryPart.CFrame = CFrame.lookAt(PrimaryPart.Position, TargetPart.Position) 
limber bobcat
# cedar junco ```lua PrimaryPart.CFrame = CFrame.lookAt(PrimaryPart.Position, TargetPart.Posit...
local Dog = script.Parent
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

-- Make sure the model has a PrimaryPart
if not Dog.PrimaryPart then
    Dog.PrimaryPart = Dog:WaitForChild("HumanoidRootPart")
end

-- Check if player is moving
local function isPlayerMoving(character)
    local humanoid = character:FindFirstChild("Humanoid")
    if not humanoid then return false end
    
    return humanoid.MoveDirection.Magnitude > 0.1
end

-- Make dog face player properly
local function makeDogFacePlayer(character)
    local playerHRP = character:FindFirstChild("HumanoidRootPart")
    if not playerHRP then return end
    
    local dogPrimary = Dog.PrimaryPart
    if not dogPrimary then return end
    
    -- Keep same height so dog doesn't tilt up/down
    local targetPosition = Vector3.new(
        playerHRP.Position.X,
        dogPrimary.Position.Y,
        playerHRP.Position.Z
    )
    
    local targetCFrame = CFrame.lookAt(dogPrimary.Position, targetPosition)
    
    -- Smooth rotation
    Dog:SetPrimaryPartCFrame(
        dogPrimary.CFrame:Lerp(targetCFrame, 0.3)
    )
end

RunService.Heartbeat:Connect(function()
    local leashAttachment = Dog:FindFirstChild("Leash_Attachment_Dog")
    if not leashAttachment then return end
    
    local rope = leashAttachment:FindFirstChild("RopeConstraint")
    if not rope or not rope.Attachment1 then return end
    
    local playerHRP = rope.Attachment1.Parent
    if not playerHRP or playerHRP.Name ~= "HumanoidRootPart" then return end
    
    local character = playerHRP.Parent
    local player = Players:GetPlayerFromCharacter(character)
    if not player then return end
    
    if not isPlayerMoving(character) then
        makeDogFacePlayer(character)
    end
end)

#

It still doesnt work

cedar junco
#

Why do you use the method Dog:SetPrimaryPartCFrame

#

Just set the CFrame of the dogs Primary to the CFrame.lookAt function and it will make the dog face the player

#

And if you don't want the dog to tilt up or down just set the Y Orientation to 0