NPC not moving when Proximity Prompt is triggered

  1. What do you want to achieve?
    When the Proximity Prompt, the humanoid moves.

  2. What is the issue?
    Even when I trigger the prompt, the humanoid doesn’t move. The code inside the function works, it jsut doesnt work when paired with the proximity prompt.

  3. What solutions have you tried so far?
    Tried doing a while loop because I thought the problem was that the code only executes once so when I trigger the prompt, it doesn’t run because it was already executed.

local Character = script.Parent.Parent
local Humanoid = Character.Humanoid

local ProximityPromptService = game:GetService("ProximityPromptService")

script.Parent.Triggered:Connect(function() 
	for i,v in pairs(game.Workspace.Nodes:GetChildren()) do
		Humanoid:MoveTo(v.Position)
		Humanoid.MoveToFinished:Wait()
	end
end)

Video:

robloxapp-20230830-2026077.wmv (646.0 KB)

Is the humanoid root part of the NPC anchored by any chance? If so, unanchor it and try again

It is not anchored. As I said the code for moving the humanoid works fine. It’s when I place it in the Proximity Prompt function that problems start occuring.

Where is the proximity prompt located?

Is this prompt inside the player’s Character or some other type of npc

It is a NPC, there is a video linked under the code

I just tried your code, in a setup like this…
image

and it worked.
So how are you setup?

I managed to get it working by changing the script in the character to be a client script, and then to fire a remote event to the server to make the server do the work.

Here’s my code:
(In character, client)

local Character = script.Parent.Parent

script.Parent.Triggered:Connect(function() 
	game.ReplicatedStorage.RemoteEvent:FireServer(Character)
end)

(In ServerScriptsService, server)

local re = game.ReplicatedStorage.RemoteEvent

re.OnServerEvent:Connect(function(plr, char)
	local Humanoid = char.Humanoid
	for i,v in pairs(game.Workspace.Nodes:GetChildren()) do
		Humanoid:MoveTo(v.Position)
		Humanoid.MoveToFinished:Wait()
	end
end)

Let me know if the same works for you!
(Also, I advise changing the name of the remote event)

Local scripts don’t work in the workspace.

I know, you can change the RunContext to “Client”
Edit: Only works on regular scripts, not local scripts

Since everyone’s getting confused.

image

That’s the setup.

Can you open the Proximity prompt, show its children?

It’s just the script.

image

image
I did this with your script and it worked well, could it be the Nodes?

Have you had any success using my code?
Please let me know so I can try again if not

Your code is not something I would advise to use, it doesn’t change anything other than making the proximity prompt triggerable by hackers from any distance.

Hadn’t really thought about exploiting - thanks for the head up!
I thought RemoteEvents were made to cut off exploiters?
Edit: Nevermind, I understand it now

Probably not.

As I said if I just remove the proximity prompt like:

local Character = script.Parent.Parent
local Humanoid = Character.Humanoid

for i,v in pairs(game.Workspace.Nodes:GetChildren()) do
	Humanoid:MoveTo(v.Position)
	Humanoid.MoveToFinished:Wait()
end

Instead of:

local Character = script.Parent.Parent
local Humanoid = Character.Humanoid

local ProximityPromptService = game:GetService("ProximityPromptService")

script.Parent.Triggered:Connect(function() 
	for i,v in pairs(game.Workspace.Nodes:GetChildren()) do
		Humanoid:MoveTo(v.Position)
		Humanoid.MoveToFinished:Wait()
	end
end)

THe NPC would walk to the nodes. So I really do feel like the proximity prompt has to do something with the problem.

It has to do something with one of your other scripts or objects, when I tried it in my studio it worked perfectly.

I don’t have any other scripts in my game.