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