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:
(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.
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.
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