How to force player to walk to the part

Objective
I want to force player to walk to the part.

script

local Players = game:GetService("Players")
local GoTo = game.Workspace.GoTo

Players.PlayerAdded:Connect(function(player)
	
	local char = player.Character
	local humanoid = char:FindFirstChild("Humanoid")
	
	--Force player to walk to the GoTo
	
	
end)

6 Likes

Try using PathfindingService to make the player walk to GoTo (More specifically GoTo.Position).
You could also use the :MoveTo() function on the player’s Humanoid (that is ONLY if there aren’t obstacles in the player’s way).

I don’t remember if you’ll have to then separately play the player’s walk/jump animations, but it shouldn’t be a big deal.

I found this cool tutorial that explains this. Consider watching it:

Otherwise, you can also refer to this page also explaining Pathfinding:

6 Likes
Players.PlayerAdded:Connect(function(player)
	
	local char = player.Character
	local humanoid = char:FindFirstChild("Humanoid")
	
	--Force player to walk to the GoTo
	humanoid:MoveTo(GoTo.Position)
end)
3 Likes

except pathfinding is useless, theres a better way to do it

1 Like

I’m curious. What is the better way?

1 Like

its… very hard to explain however this video might help you

1 Like

Ok so It was work

local Players = game:GetService("Players")
local GoTo = game.Workspace.GoTo

Players.PlayerAdded:Connect(function(player)
	
	local char = player.Character
	local humanoid = char:FindFirstChild("Humanoid")
	
	--Force player to walk to the GoTo
		local Controls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()---GetControls
	    Controls:Disable() 
		humanoid:MoveTo(GoTo.Position)
       wait(5)
Controls:

end)
5 Likes

The only problem with this is that if someday you put a obstacle in between the destination and the player, the player will not move around it. Right now, it should work fine. Just a heads up.

They can simply add pathfinding waypoints around the object or use pathfinding states such as automatically jumping or climbing truss’s or making the players parts can collide off for the time being so if any parts were to get in the way they wouldn’t affect the player at all.

1 Like