I have this bug where whenever the zombies reach any waypoint i made they’ll stop for a short period of time (as shown in the video) that only happens when i start the game with the play button, running it does not glitches.
local mob = script.Parent.Parent
local Paths = game.Workspace.Path
local Humanoid = script.Parent
local Animation = script:WaitForChild("Animation")
local AnimationTrack = Humanoid:LoadAnimation(Animation)
-- Destroys the mob body when dead
Humanoid.Died:Connect(function()
local rewardOwner = game.Players[mob.RewardOwner.Value]
rewardOwner.Money.Value = rewardOwner.Money.Value + Humanoid.MaxHealth * Humanoid.WalkSpeed
mob:Destroy()
end)
-- Starts walking to the pathpoints when the mob gets to the Workspace
mob.AncestryChanged:Connect(function(child, parent)
wait(0.25)
AnimationTrack:Play()
AnimationTrack:AdjustSpeed(Humanoid.WalkSpeed/2)
if parent == game.Workspace.Mobs then
for PathNumber, Path in pairs(game.Workspace.Path:GetChildren()) do
if Path ~= Paths.Part1 then
Humanoid:MoveTo(Paths["Part"..PathNumber].Position)
Humanoid.MoveToFinished:Wait()
end
end
else
print(script.Parent.Name .. " shouldn't have this parent")
end
end)
while mob.Parent == game.Workspace.Mobs do
wait(1)
mob.DistanceTraveled.Value = mob.DistanceTraveled.Value + Humanoid.WalkSpeed
end