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