i just have to say, i know nothing about roblox AI, all i know is that roblox AI is really bad (apparently).
the AI i have “created” was a free model, but it doesnt work, it will not jump or fall of platforms, and
gets stuck easily on walls its trying to jump up on, heres a video of whats happening:
the AI is very bad, and doesnt work properly half the time, im just hoping that its maybe just a error from me, but it might be robloxs bad AI.
if theres any modules or scripts that already exist, or you know what the problem is, please reply, this is very important, also if it works, i will make your reply the solution. bye!
Heres the roblox script if you want it, its not mine so i dont care about it.
sorry if the script is to long, i am still pretty new to this.
local Pathfinding = game:GetService("PathfindingService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Path = Pathfinding:CreatePath({
AgentHeight = 5;
AgentRadius = 1;
AgentCanJump = true;
WaypointSpacing = 1.2;
Cost = {
Water = 100;
DangerZone = math.huge
}
})
local Character = script.Parent
local humanoid = Character:WaitForChild("Humanoid")
local WaypointIndex = 1
local Waypoints = {}
local ReachedConnection
local BlockedConnection
function displayPath(waypoints)
local colorwalk = BrickColor.White()
local colorjump = BrickColor.Blue()
local colorclimb = BrickColor.Green()
for index, waypoint in pairs(waypoints) do
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Size = Vector3.new(1,1,1)
part.Transparency = 0.5
part.Position = waypoint.Position
part.Parent = workspace
if waypoint.Action == Enum.PathWaypointAction.Jump then
part.BrickColor = colorjump
end
if waypoint.Action == Enum.PathWaypointAction.Walk then
part.BrickColor = colorwalk
end
local Debris = game:GetService("Debris")
Debris:AddItem(part, 0.1)
end
end
local function findTarget()
local maxDistance = 500
local nearestTarget
for index, player in pairs(Players:GetPlayers()) do
if player.Character then
local target = player.Character
local distance = (Character.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude
if distance < maxDistance then
nearestTarget = target
maxDistance = distance
end
if distance < 5 then
nearestTarget.Humanoid:TakeDamage(0)
end
end
end
return nearestTarget
end
local function followPath(destination)
local success, errormessage = pcall(function()
Path:ComputeAsync(Character.PrimaryPart.Position, destination)
end)
if success and Path.Status == Enum.PathStatus.Success then
Waypoints = Path:GetWaypoints()
displayPath(Waypoints)
BlockedConnection = Path.Blocked:Connect(function(blockedWaypointIndex)
if blockedWaypointIndex >= WaypointIndex then
humanoid:MoveTo(Waypoints[WaypointIndex].Position)
end
ReachedConnection:Disconnect()
end)
--blocked connection
ReachedConnection = humanoid.MoveToFinished:Connect(function(reached)
if reached and WaypointIndex < #Waypoints then
WaypointIndex += 1
if Waypoints[WaypointIndex].Action == Enum.PathWaypointAction.Jump then
humanoid.Jump = true
end
humanoid:MoveTo(Waypoints[WaypointIndex].Position)
else
ReachedConnection:Disconnect()
BlockedConnection:Disconnect()
end
end)
WaypointIndex = 2
humanoid:MoveTo(Waypoints[WaypointIndex].Position)
else
warn("Path not Computed!", errormessage)
end
end
while wait() do
local target = findTarget()
if target then
print(target.Name)
followPath(target.HumanoidRootPart.Position)
end
end