How can I teleport a player when they use a proximity prompt? I tried following the tutorial but all it did is get me more confused. I don’t know any scripting so if you just tell me code I won’t know where to put it so please tell me what to put it under in explorer. Thanks everyone!
P.S. I will be teleporting them both within the game and to other games/places depending on the prompt so you can give me either code and I’ll be able to do it.
local proximityPrompt = script.Parent
local partToTeleportTo = workspace.PartToTeleport
proximityPrompt.Triggered:Connect(function(player) -- When the proximity prompt is triggered, it will return a player value. We can use this in our code!
local character = player.Character -- This returns the character model of the player
character.HumanoidRootPart.Position = partToTeleportTo.Position -- This sets the humanoidrootpart of the player to the part you want to teleport to's position. Since the character is connected to the humanoidRootPart, the whole character will come along!
end)
Read the comments to find out what each line of code does!
Hope this helps!
---- Note: Make sure you enabled "Allow Third Party Teleports" In Game Settings > Security.
local TeleportService = game:GetService("TeleportService") --- Get Teleport Service.
local Part = script.Parent ---- Part.
local PlaceId = 1234567890 ---- Replace this with place id.
local ProximityPrompt = Part.ProximityPrompt ---- Get ProximityPrompt In Part.
ProximityPrompt.Triggered:Connect(function(Player) ---- Runs Code When ProximityPrompt Triggered.
TeleportService:Teleport(PlaceId, Player)
end)
Alright, that is nothing to do with the proximity prompt then. Where have you put the proximity prompt at? Remember, you have to put it inside a part. And also remember to create a separate part called ‘PartToTeleport’ in workspace!
It’s not that you are a bad scripter. You are new to developing, and you need to keep persisting! Maybe work on this with a fresh mind tomorrow and you might just find a solution!