How to force player using pathfindingservice

if you dont get it then here is the thing:

when i move my character the pathfinding messes up

and i am trying to achieve:

the player cant move* its character until the character has reached its destination

here is my current code for now

local function MovePlayers(Player, Part, Speed)
	-- Define humanoid then move them
	local character = Player.Character
	local Humanoid = character.Humanoid
	
	-- Change speed
	Humanoid.WalkSpeed = Speed
	
	local path = PathfindingService:CreatePath()
	path:ComputeAsync(character.PrimaryPart.Position, Part.Position)
	for _, WayPoints in pairs(path:GetWaypoints()) do
		Humanoid:MoveTo(WayPoints.Position)
		Humanoid.MoveToFinished:wait()
	end
end

idk how to do this the path finding service code i just researched for it

To get the controls you could do.

local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()

To disable/ enable it do

controls:Disable()
controls:Enable()

Personally, I’m not good with pathfinding so I can’t really help. But, you could alternatively move the player’s humanoid, using “MoveTo”, which is done by walking to a specific position of a part or ect. Then you could use a touched event to make sure that the player has actually touched the part, and enable the controls again.

1 Like

and for some reason when the character walks its kinda glitchy they stop at one waypoint everytime

Can you provide your code so we can look into it.