local PathfindingService = game:GetService("PathfindingService") local function findPath(player) local human = player.Character local humanoid = human.Humanoid local endDestination = workspace.Obby.WalkToLocation local path = PathfindingService:CreatePath() path:ComputeAsync(human.HumanoidRootPart.Position, endDestination.Position) if path.Status == Enum.PathStatus.Success then local Nodes = path:GetWaypoints() for i,v in pairs(Nodes) do local node = Instance.new("Part", workspace) node.Size = Vector3.new(1,1,1) node.Position = v.Position node.Anchored = true node.CanCollide = false humanoid.WalkToPoint = v.Position humanoid:MoveTo(v.Position) end end end game.ReplicatedStorage.Remotes.FindPath.OnServerEvent:Connect(function(player) findPath(player) end)
when i replace it with a npc it works but on the localplayer it finds the path but doesnt move the player
you can try this to disable the players Movement note: this only disables all keyboard controls
local ContextActionService = game:GetService("ContextActionService") local Name = "freezeMovement" ContextActionService:BindAction( Name, function() return Enum.ContextActionResult.Sink end, false, unpack(Enum.PlayerActions:GetEnumItems()) )
type to unfreeze
ContextActionService:UnbindAction(Name)
and heres a gif on what it looks like with a small maze and your pathfinding streamable.com/q5s6u7 Full code
local ContextActionService = game:GetService("ContextActionService") local PathfindingService = game:GetService("PathfindingService") local Name = "freezeMovement" ContextActionService:BindAction( --Stops player from moveing Name, function() return Enum.ContextActionResult.Sink end, false, unpack(Enum.PlayerActions:GetEnumItems()) ) local function findPath(player) local human = player.Character local humanoid = human.Humanoid local endDestination = workspace.Move local path = PathfindingService:CreatePath() path:ComputeAsync(human.HumanoidRootPart.Position, endDestination.Position) if path.Status == Enum.PathStatus.Success then local Nodes = path:GetWaypoints() for i,v in pairs(Nodes) do local node = Instance.new("Part", workspace) node.Size = Vector3.new(1,1,1) node.Position = v.Position node.Anchored = true node.CanCollide = false humanoid.WalkToPoint = v.Position humanoid:MoveTo(v.Position) humanoid.MoveToFinished:Wait() end ContextActionService:UnbindAction(Name)--Unlock player movement after the loop end end findPath(game:GetService("Players").LocalPlayer)