How would I make my NPC climb stairs?

Hello,
I’m writing an AI Script for my NPC. I want it to be able to climb stairs. But it doesn’t. It just goes to the wall and gets stuck, it’s not smart enough to climb stairs.
Script:

local npc = script.Parent
local humanoid = npc.Humanoid
npc.PrimaryPart:SetNetworkOwner(nil)


local function getPath(destination)
	local PathfindingService = game:GetService("PathfindingService")

	local pathParams = {
		["AgentHeight"] = 2,
		["AgentRadius"] = 5,
		["AgentCanJump"] = false
	}

	local path = PathfindingService:CreatePath(pathParams)

	path:ComputeAsync(npc.HumanoidRootPart.Position, destination.Position)

	return path
end


local function walkTo(destination)

	local path = getPath(destination)

	if path.Status == Enum.PathStatus.Success then
		for index, waypoint in pairs(path:GetWaypoints()) do
			humanoid:MoveTo(waypoint.Position)
			humanoid.MoveToFinished:Wait()
		end
	else
		humanoid:MoveTo(destination.Position - (npc.HumanoidRootPart.CFrame.LookVector * 10))
	end
end

function patrol()
	local waypoints = workspace.Waypoints:GetChildren()
	local randomNum = math.random(1, #waypoints)
	walkTo(waypoints[randomNum])
end

while wait(math.random(6,12)) do
	patrol()
end


How would I make it go up stairs?

1 Like

I’d think that instead of just doing math do do it, I would just make an invisible slope to help it climb up, I’m pretty sure it’d detect that as a valid path.

1 Like

What do you mean? How could I do this?

Overlay a wedge with transparency value 1 at the same location of the stairs. Make sure it’s the same size as the stairs. This also helps with UX because the camera doesn’t go BRRR when walking up the stairs.

1 Like