So me and my dev partner are working on ai for one of our creatures, but the ai for the creature is very buggy were not sure how to fix it
I tested the same code on a dummy and it works perfectly
spawn(function()
while true do
wait()
for _,player in pairs(game.Players:GetPlayers()) do
if player.Character then
local CharacterHumanoidRootPart = player.Character.HumanoidRootPart
if (CharacterHumanoidRootPart.Position - MonsterHumanoidRootPart.Position).Magnitude < 61 then
local path = PathfindingService:CreatePath()
path:ComputeAsync(MonsterHumanoidRootPart.Position, CharacterHumanoidRootPart.Position)
local waypoints = path:GetWaypoints()
for _, waypoint in pairs(waypoints) do
local part = Instance.new("Part")
part.Shape = "Ball"
part.Material = "Neon"
part.Size = Vector3.new(0.6, 0.6, 0.6)
part.Position = waypoint.Position
part.Anchored = true
part.CanCollide = false
part.Parent = game.Workspace
if waypoint.Action == Enum.PathWaypointAction.Jump then
MonsterHumanoid.Jump = true
end
--MonsterHumanoid:MoveTo(waypoint.Position)
Path:Run(CharacterHumanoidRootPart.Position)
--MonsterHumanoid.MoveToFinished:Wait()
end
end
end
end
end
end)