I’m trying to use PathfindingService to pathfind to a position. The pathfinding works fine. The problem is that when I try to make the humanoid move to a waypoint with :MoveTo(), it just simply does nothing.
Here is my pathfinding and moving code. It’s a script inside of ServerScriptService
local PathfindingService = game:GetService("PathfindingService")
game.ReplicatedStorage.RemoteEvents.Pathfind.OnServerEvent:Connect(function(Player, Troop, Radius, Height, Destination, Jump)
local PathParams = {AgentRadius = Radius, AgentHeight = Height, CanJump = true}
local Path = PathfindingService:CreatePath(PathParams)
Path:ComputeAsync(Troop.HumanoidRootPart.Position, Destination)
local Waypoints = Path:GetWaypoints()
for i,Waypoint in pairs(Waypoints) do
Troop.Humanoid:MoveTo(Waypoint.Position)
Troop.Humanoid.MoveToFinished:Wait()
end
end)
I’m not sure what is wrong with it. Could it be my AgentRadius and AgentHeight? I tried changing them to 0 but still no different result. Troop is the character thing that i’m trying to move.