Issue with this AI, Does not walk to parts

These AI gun bots are meant to go to parts to see if the player is there. But they stand still. In baseplate it works but terrian they just stand still. Whats the issue?


can you show us the script you use for the movement?

Ok

local NPC = script.Parent
local ha = script.Parent:FindFirstChildWhichIsA("Humanoid")
local pathfinding_service = game:GetService("PathfindingService")
local debounce = false
local tabl = {game.Workspace.P1,game.Workspace.P2,game.Workspace.p3}
local Pathrough =  tabl[math.random(1, #tabl)] 
local Prompts = {
	[1] = ("Moving.");
	[2] = ("Heading To Location.");
	[3] = ("Moving To Location");
};
coroutine.wrap(function()
	while wait(2)  do
		game:GetService("Chat"):Chat(script.Parent.HumanoidRootPart, Prompts[math.random(1,#Prompts)], Enum.ChatColor.Red)
	end

end)()
function getClosestPlayer()
	local closest_player, closest_distance = nil, 1000
	for i, player in pairs(workspace:GetChildren()) do
		if Pathrough then
			local distance = (NPC.PrimaryPart.Position - Pathrough.Position).Magnitude
			if distance < closest_distance then
				closest_player = Pathrough
				closest_distance = distance
			end
		end
	end
	return closest_player, closest_distance
end

while true do
	local path = pathfinding_service:CreatePath(({
		["AgentRadius"] = 100000000000,
		["AgentHeight"] = 0,
		["AgentCanJump"] = false,
	}))

	local player, distance = getClosestPlayer()
	if player and distance > 1 then
		path:ComputeAsync(NPC.HumanoidRootPart.Position, Pathrough.Position, 10000000000)

		local waypoints = path:GetWaypoints()
		for _, waypoint in pairs(waypoints) do  
			ha:MoveTo(waypoint.Position)
			script.Parent.Monsta.MoveToFinished:Connect(function()
				script.Disabled = true
				wait(1)
				script.Disabled =false				
			end)
			while true do
				local distance = (NPC.PrimaryPart.Position - waypoint.Position).Magnitude
				local distance_from_player = (NPC.PrimaryPart.Position -Pathrough.Position).Magnitude
				if distance < 34999 then
					break
				end
				if distance_from_player < 109999 then
					ha:MoveTo((NPC.HumanoidRootPart.CFrame*CFrame.new(0,0,-3)).p)
					break
				end
				wait()
			end

			for i, waypoint in pairs(waypoints) do
				if waypoint.Action == Enum.PathWaypointAction.Jump  then
					if not debounce then
						debounce = true
						print("da")

						ha:ChangeState(Enum.HumanoidStateType.Jumping)		
						wait(13)
						debounce = false
					end
				end
			end
		end
	end
	wait()
end

Try turning “AgentCanJump” to true, see if that does anything. And fix the Agent radius… that’s supposed to be about half of the character’s width, 100000000000 studs is much too big…


Ive tried it, It still doesnt work. Also thats the terrian. Do you think its the terrian itself?

It’s not the terrain, there just seems to be a few things askew in your script. I don’t really have time to look at it much now, but I’d compare it to some other AI scripts and see what’s up.

Yo!
Take a look at your line 46.
It says “script.Parent.Monsta”, which is supposed to be a humanoid.
Try changing Monsta to Humanoid or renaming your Humanoid to “Monsta”, doesn’t matter
Also try to use default AgentRadius and AgentHeight (2,5)

P.S tested the script, works fine on terrain for me

tried both of them. For some reason it doesnt work.