This script is supposed to detect when you touch a part and when you do it will move you to a certain part. But it doesnt
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid") script.Parent.Touched:Connect(function(touch) humanoid:MoveTo(game.Workspace:FindFirstChild("DestinationStop")) end)
It's basically because MoveTo requires a Vector3 Value, and since you tried to put a object instead of it, It's won't work.
You'd need to get the part's position as It's a vector3 value, which can be done by simply changing
humanoid:MoveTo(game.Workspace:FindFirstChild("DestinationStop"))
to
humanoid:MoveTo(game.Workspace:FindFirstChild("DestinationStop").Position)
Hopefully that helps with your issue! Make sure to read read the MoveTo article as It'll for sure help you with some issues and questions you might have about it, make sure to accept if it solved your issue!
Your problem is being caused because you’ve passed the Model:MoveTo()
method a Part. This won’t preform the anticipated movement as it expects a Vector3
of the Part. This is the Part’s raw position. You can use .p
at the last parenthese to translate the Object to it’s Vector3.
Don’t use the Humanoid, this will make it walk with :MoveTo
, use the Character instead as it is a method primarily use for Models.
local Part = script.Parent Part.Touched:Connect(function(hit) --// Use this to get the Character that touched the Part local Part = workspace:FindFirstChild("DestinationStop") local Character = hit.Parent if (game:GetService("Players")[Character.Name]) then --// Reassurance Character:MoveTo(Part.p) end end)
Hope this helps! If so, don’t forget to accept!
You would need to get the part's position because MoveTo takes a Vector3 Value.
So like this:
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid") script.Parent.Touched:Connect(function(touch) humanoid:MoveTo(game.Workspace:FindFirstChild("DestinationStop").Position) end)
If there's any other issues, it's probably because of how you're handing when something touches your part.