I’m pretty sure this in the right category.
-
What do you want to achieve? Keep it simple and clear!
The zombies should keep moving to every point even if they take damage. -
What is the issue? Include screenshots / videos if possible!
Video
The zombies that take damage walk to their next point, but then the point after that will result in it reaching the point then not going to the next. -
What solutions have you tried so far?
Changing the way :MoveTo() is called. (including a instance argument, that didn’t work.)
Here is the pathfinding code for whoever needs it
local function moveTo(humanoid, targetPoint)
local targetReached = false
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
end)
humanoid:MoveTo(targetPoint)
while not targetReached do
if not (humanoid and humanoid.Parent) then
break
end
if humanoid.WalkToPoint ~= targetPoint then
break
end
humanoid:MoveTo(targetPoint)
task.wait()
end
if connection then
connection:Disconnect()
connection = nil
end
end
-- thanks devhub!
script.Parent.Humanoid.Died:Connect(function()
for i,v in pairs(script.Parent.Humanoid.Animator:GetPlayingAnimationTracks()) do
v:Stop()
end
task.wait(4)
for i,v in pairs(script.Parent:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("Decal") then
game:GetService("TweenService"):Create(v,TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Transparency=1}):Play()
end
end
task.wait(1)
script.Parent:Destroy()
end)
local points = game.Workspace.PathPoints:GetChildren()
for i,v in pairs(points) do
moveTo(script.Parent.Humanoid,v.Position)
end
local points = game.Workspace.PathPoints:GetChildren()
for i,v in pairs(points) do
moveTo(script.Parent.Humanoid,v.Position)
end
game.Workspace.GAME_VALUES.BaseHealth.Value -= script.Parent.Humanoid.Health
script.Parent.Humanoid.Health = 0
I have no idea why the zombies taking damage would affect :MoveTo().
Thanks in advance for your help!