So, I decided to make a simple NPC follow script and I took the plunge. I did it, however, the NPC movement stutters horribly and some walk absolutely slow even though they have the same speed. Does anyone know what this could be?
Script that moves the NPC:
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://180426354"
while wait() do
if script.Parent.Contents.Follow.Value == true and script.Parent.Contents.NPC.Value == 0 then
local GetOwner = script.Parent.Contents.Owner.Value
local Distance = (script.Parent.PrimaryPart.Position - game.Workspace[GetOwner].PrimaryPart.Position).Magnitude
if Distance > 3 then
local LoadAnim = script.Parent.Humanoid:LoadAnimation(animation)
LoadAnim.Looped = true
script.Parent.Humanoid:MoveTo((game.Workspace[GetOwner].HumanoidRootPart.CFrame*CFrame.new(0,0,3)).p)
LoadAnim:Play()
script.Parent.Humanoid.MoveToFinished:Wait()
LoadAnim:Stop()
end
else
local GetNPC = script.Parent.Contents.NPC.Value
local NPC = game.Workspace.NPC:FindFirstChild(GetNPC)
local Distance = (script.Parent.PrimaryPart.Position - game.Workspace.NPC[GetNPC].PrimaryPart.Position).Magnitude
if Distance > 3 then
local LoadAnim = script.Parent.Humanoid:LoadAnimation(animation)
LoadAnim.Looped = true
script.Parent.Humanoid:MoveTo((NPC.HumanoidRootPart.CFrame*CFrame.new(0,0,3)).p)
LoadAnim:Play()
script.Parent.Humanoid.MoveToFinished:Wait()
LoadAnim:Stop()
end
end
end
Thanks for any help.