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
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.