So, whenever i'm near the npc, the animation freeze. And when he's at his original position, the animation won't stop
wait(1)
local check = game.ReplicatedFirst.Enemies
if check then
game.ReplicatedFirst.Enemies.Parent = game.Workspace.Camera
end
local player = game.Players.LocalPlayer
local character = player.Character
local body = character:WaitForChild("HumanoidRootPart")
local distance = 30
local loaded = false
while true do
wait(0.01)
for i,v in next,game.Workspace.Camera.Enemies:GetChildren() do
if (body.Position - v.HumanoidRootPart.Position).magnitude < distance then
v.Humanoid:MoveTo(body.Position, body)
v.HumanoidRootPart.Size = Vector3.new(4.2,4.2,4.2)
v.Humanoid:LoadAnimation(script.Walking):Play()
else
if v.HumanoidRootPart.Position ~= v.OriginalPosition.Value then
v.Humanoid:MoveTo(v.OriginalPosition.Value)
else
v.Humanoid.MoveToFinished:Wait()
v.HumanoidRootPart.Size = Vector3.new(3.66,3.66,3.66)
v.Humanoid:LoadAnimation(script.Walking):Stop()
end
end
end
end
