Proximity Prompt Used For Teleportation Not Working

I was using the Proximity Prompt to teleport players to a location, but it seems like the Proximity Prompt wasn’t working.

Here is my current script

local Prompt = script.Parent:WaitForChild("ProximityPrompt")
local db = false
local dbwait = 3.5

Prompt.Triggered:Connect(function(Player)

		if game.Players:GetPlayerFromCharacter(Player.Parent) and db == false then
			local Root = Player.Parent:FindFirstChild("HumanoidRootPart")

			Root.CFrame = CFrame.new(workspace.FromTele.Position)
			db = true
			wait(dbwait)
			db = false
		end
	end)

Note: “FromTele” is the part that I want players to teleport to.

When I go to test it and try to use in the the Proximity Prompt, nothing pops up in the output, no line saying there is an error. I’ve looked at multiple Proximity Prompt tutorials and they are all from months ago, has something changed with enabling Proximity Prompt?

If you require any other information please ask.

1 Like

Triggered passes the Player that triggered the prompt. Player.Parent always points to game.Players. You already have the player so there’s no need to try to find it again via GetPlayerFromCharacter

Oh I see, what would I replace there then?

Player is the player inside of the players section in the explorer so you cannot get the humanoidrootpart with this method you should use player.Character:FindFirstChild("HumanoidRootPart")

If I do this,

local player.Character:FindFirstChild("HumanoidRootPart")

the period after the “player” and the “player.CFrame” (which is the next line of code) are underlined in red.

You don’t need to make a variable

After the trigger action use the that string

player.Character:FindFirstChild("HumanoidRootPart").CFrame =

Sorry if I’m being such a bother, I can’t seem to understand.

So I get rid of this line,

local Root = Player.Parent:FindFirstChild("HumanoidRootPart")

then I put this

player.Character:FindFirstChild("HumanoidRootPart").CFrame =

under this?

Prompt.Triggered:Connect(function(Player)

You want to replace the line
local Root = Player.Parent:FindFirstChild("HumanoidRootPart")
with
local Root = Player.Character:FindFirstChild("HumanoidRootPart")

and also get rid of the game.Players:GetPlayerFromCharacter(Player.Parent) and
from
if game.Players:GetPlayerFromCharacter(Player.Parent) and db == false then

Then it should work!

1 Like

Yes it worked! Thank you so much.

No problem! If you don’t mind, could you mark the solution?
Thanks!

2 Likes