This is the code I use for the cat movement, I use module:
local PathFinding = require(script:WaitForChild("PathFinding"))
local NPC = script.Parent
local owner = NPC.Parent
local targetPlayerRootPart = owner:FindFirstChild("HumanoidRootPart")
while true do
task.wait(0.1)
local ownerPos = targetPlayerRootPart.Position
if targetPlayerRootPart then
local distance = (NPC.HumanoidRootPart.Position - targetPlayerRootPart.Position).Magnitude
if distance > 10 then
PathFinding.WalkTo(NPC, ownerPos+Vector3.new(4,0,4))
end
end
end
The animation script:
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local walk = animator:LoadAnimation(script:WaitForChild("Walk"))
local sit = animator:LoadAnimation(script:WaitForChild("Sit"))
local loaf = animator:LoadAnimation(script:WaitForChild("Sit to Loaf"))
local sitting = animator:LoadAnimation(script:WaitForChild("Sitting"))
local loafing = animator:LoadAnimation(script:WaitForChild("Loafing"))
humanoid.Running:Connect(function(speed)
if speed > 0 then
if not walk.IsPlaying then
sitting:Stop()
loafing:Stop()
walk:Play()
end
else
if walk.IsPlaying then
walk:Stop()
sit:Play()
end
end
end)
sit.Ended:Connect(function()
sitting:Play()
task.wait(4)
sitting:Stop()
loaf:Play()
end)
loaf.Ended:Connect(function()
loafing:Play()
end)
I cannot find out why the cat randomly dashes forward like that. if you want, I can send the module code file since discord wont alow me to send it hee since there is a text cap. the code is too long
** You are now Level 6! **

