I am testing an artificial intelligence that marks where it has to go but when I put it to work it does not detect the doors and stays glued to the wall, what do I do?
My code here:
local dummy = script.Parent
local ball = workspace.PathFindBall
for _, object in pairs(dummy:GetChildren()) do
if object:IsA("BasePart") then
object:SetNetworkOwner()
end
end
local pathfind = game:GetService("PathfindingService")
while wait() do
function createPath(target)
local Agentparams = {
AgentHeight = 1,
AgentRadius = 1,
AgentCanJump = false
}
local path = pathfind:CreatePath(Agentparams)
path:ComputeAsync(dummy.HumanoidRootPart.Position, ball.Position)
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
return path, waypoints
end
end
function showpath(path)
local waypoints = path:GetWaypoints()
for _, waypoint in ipairs(waypoints) do
local part = Instance.new("Part", workspace)
part.Shape = Enum.PartType.Ball
part.Material = Enum.Material.Neon
part.Anchored = true
part.CanCollide = false
part.Size = Vector3.new(1,1,1)
part.Position = waypoint.Position
game:GetService("Debris"):AddItem(part, 5)
end
end
function MovePathFind()
local target = ball
if target then
local path, waypoints = createPath(target)
if path and waypoints then
local showthepath = showpath(path)
for _, waypoint in pairs(waypoints) do
local positionway = waypoint.Position
dummy.Humanoid:MoveTo(positionway)
dummy.Humanoid.MoveToFinished:Wait(5)
end
end
end
end
MovePathFind()
end