I am making a zombie ai that attacks players in a 100 stud radius, but the zombie won’t go towards the player
robloxapp-20200910-1956180.wmv (1.5 MB)
The Script
while wait() do
local humRootPart = FindTarget()
if humRootPart then
local zombiePath = PFS:CreatePath()
zombiePath:ComputeAsync(zombieTorso.Position, humRootPart.Position)
local waypoints = zombiePath:GetWaypoints()
for i, v in pairs(waypoints) do
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Size = Vector3.new(0.6,0.6,0.6)
part.Position = v.Position + Vector3.new(0,2,0)
part.Material = Enum.Material.Neon
part.Shape = Enum.PartType.Ball
part.Parent = workspace
if waypoints.Action == Enum.PathWaypointAction.Jump then
zombieHum:ChangeState(Enum.HumanoidStateType.Jumping)
end
humRootPart.Changed:Connect(function(Position)
zombieHum:MoveTo(v.Position)
zombieHum.MoveToFinished:Wait(1)
zombieHum.WalkToPart = humRootPart
end)
end
else
wait(1)
zombieHum:MoveTo(zombieTorso.Position + Vector3.new(math.random(-50,50), 0, math.random(-50,50)))
end
end