Hello I have a problem with my zombies is that it moves strangely, I mean it spins for no reason and I would like to prevent its doing but I don’t know how to solve the problem.
Video Problem :
Script i Made :
spawn(function()
repeat wait()
spawn(function()
local PlayerAttack = game.Players:GetChildren()[math.random(1,#game.Players:GetChildren())]
if PlayerAttack.Character:FindFirstChild("Torso") then
if Zombie:FindFirstChild("HumanoidZombie") then
local Humanoid = Zombie:WaitForChild("HumanoidZombie")
local Torso = Zombie:WaitForChild("Torso")
local path = PathfindingService:CreatePath()
for _,Player in pairs(game.Players:GetChildren()) do
if PlayerAttack == nil then
PlayerAttack = Player
else
if (Torso.Position - PlayerAttack.Character:WaitForChild("Torso").Position).magnitude < (PlayerAttack.Character.Torso.Position - Torso.Position).magnitude then
PlayerAttack = Player
end
end
end
if PlayerAttack.Character:FindFirstChild("Torso") then
path:ComputeAsync(Torso.Position, PlayerAttack.Character:WaitForChild("Torso").Position)
for _,waypoint in pairs(path:GetWaypoints()) do
Humanoid:MoveTo(waypoint.Position)
Humanoid.MoveToFinished:Wait(2)
end
end
end
end
end)
until humanoid.Health == 0
end)
This is the first time I use the pathfinding