Need help with moveto

Hello, I am fairly new to scripting and I’m trying to learn. I am trying to make whenever a player presses e on a Proximity Prompt their character will move to a part in the model. Here’s my code:

local clickdetector = script.Parent.ClickDetector
local humanoid = script.Parent.Humanoid
script.parent.ClickDetector.MouseClick:connect(function(player)
end)
humanoid:MoveTo(script.Parent.PlayerPos)
humanoid.MoveToFinished:wait()
script.parent.ClickDetector.MouseClick:connect(function(player)
end)


local clickdetector = script.Parent.ClickDetector
script.parent.ClickDetector.MouseClick:connect(function(player)
local Char = player.Character
local humanoid = Char.Humanoid
humanoid:MoveTo(script.Parent.PlayerPos.Position)
humanoid.MoveToFinished:wait()

end)

@KabukiInfo if u have any questions then feel free to ask

1 Like

Your current implementation works with a “ClickDetector” not a “ProximityPrompt”, if you want this to work with a prompt then use the following.

local Part = script.Parent
local Prompt = Part.ProximityPrompt
local Position = Part.PlayerPos

Prompt.Triggered:Connect(function(Player)
	local Character = Player.Character
	local Humanoid = Character.Humanoid
	Humanoid:MoveTo(Position)
	Humanoid.MoveToFinished:Wait()
end)

Remember to put a ProximityPrompt instance inside the part.