How would you make a script that tps the player when they activate a proximityprompt?

simple question, if someone presses e on the proximity prompt then they get tped to a new game

Check out the docs on ProximityPrompts and TeleportService.

ProximityPrompt.Triggered will fire when a player triggers the prompt, and you can use the TeleportService:TelportAsync() method to teleport players.

im a new scripter so idk any of those stuff and i cant understand it

What do you not understand?
Roblox has a couple tutorials on scripting (here, here). You can also find some beginner guides on Youtube.

i still dont understand how to tp someone when a prox is toggled

Please look this up on Youtube; from a quick search I’m seeing multiple videos on this subject. Please also run a search on the forums before posting as there are several topics that already have discussed this.

Note that this example is untested and you will need to adapt it a bit to your need:

local TeleportService = game:GetService("TeleportService") -- Gets the TeleportService
local ProximityPrompt = script.Parent -- Replace this with wherever your proximity prompt is located

ProximityPrompt.Triggered:Connect(function(player) -- This function will run when the prompt is triggered. The "player" parameter will be automatically set to whichever player triggered the prompt.
	local success, result = pcall(function() -- pcall will run the function it envelopes, but will catch any errors that may occur, preventing the script from stopping. This is necessary for certain methods, like TeleportAsync, that can occasionally error.
		return TeleportService:TeleportAsync(placeId, {player}) -- Teleports player to the placeId of your choice. Replace placeId with your placeId
	end) -- There are more efficient ways to write this, but this is easier to understand.
	
	if not success then -- If the pcall errored and the teleport failed
		warn("Teleport failed:", result)
	end
end)

TeleportService.TeleportInitFailed:Connect(function(player, teleportResult, errorMessage, placeId, teleportOptions) -- This will run when a teleport fails
	print("Teleport failed:", errorMessage)
	-- Try to make your own retry system, you will learn more by doing
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.