Proximity Prompt Not Activating

Hello, I have a part that when the player interacts with the proximity prompt located within it, it is supposed to teleport the player out of a “base”.

Here is the code I am using to detect the prompt (located in ServerScriptService):

local Base = game.Workspace:WaitForChild("Base");

local entrance = Base:WaitForChild("Entrance");
local exit = Base:WaitForChild("Exit");
local exitPos = CFrame.new(entrance.Position + Vector3.new(0, 5, 0));
local entrancePos = CFrame.new(exit.Position - Vector3.new(0, 5, 11));

exit:WaitForChild("BaseExit").Triggered:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait();

	character.HumanoidRootPart.CFrame = exitPos;

	print("exit");
end)

entrance:WaitForChild("BaseExit").Triggered:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait();

	character.HumanoidRootPart.CFrame = entrancePos;

	print("entrance");
end)

The problem is that for some reason this never gets triggered? Even the print statement doesn’t print something.

Here are my proximity prompt settings:
image
(and yes it does show to the player and the player can interact with it)

Anyways, I have been trying to fix this for a while and still can’t seem to find a solution despite visiting multiple different forum posts.

2 Likes

Well it seems “exit” is being recognized as a function or something so try changing the name.

Also instead of using waitforchild and then .Triggered just define the promts at the beginning of the script, this could also help

Point of story: change the name of exit and it should work

3 Likes

Changing exit to exitHatch doesn’t seem to fix the problem, though the fact that the code might be recognizing exit as the function exit() could have been another problem.

4 Likes

You can try chaning the duration to 1 or something else low because maybe the 0 duration could be messing it up.

2 Likes

This doesn’t work either. I tried changing the duration to half a second and the issue still persists.

3 Likes

Are there two proximity promts in one object? This could cause it. I cant really tell by your code but it kinda seemed like it

1 Like

Remove the :WaitForChild()'s. By the time the base loads, its children would have loaded as well. So when you’re waiting for a child that had already loaded the script will keep yielding for it which is why it cannot detect your triggers

2 Likes

No, there is only the one prompt.

1 Like

This doesn’t change anything either. But on that note, does :WaitForChild(Parent) also wait for all the children of the Parent object to be loaded?

1 Like

Well like @MysteryX2076 said, you could remove the WaitForChilds. Also how are you saying the promt is a child of two different parts?

1 Like

Yes it does, since they all come in a ‘package’ so the script will wait for all of them

1 Like

Does anything show up on the console when you trigger it?

1 Like

Nope, nothing at all. Even when I used exit as a variable name, nothing showed up on the console / output.

1 Like

Just to be clear. .You are using a server script, correct?

1 Like

Yes. I am using a serverscript in serverscriptservice.

1 Like

try removing the semicolons at the end of the lines on your script

1 Like

Make sure exit is renamed, which im pretty sure you did.

Also you’re saying the promt is the child of both the exit and entrance which will not work

1 Like

Kind of an experimental fix, but try removing player.CharacterAdded:Wait. Since the character is already loaded in for them to trigger it.

1 Like

The entrance has a different prompt (separate from the exit prompt)

2 Likes

Oh, i thought they were the same because they are named the same. But that shouldn’t mess anything up

1 Like