Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I can't teleport the player between places in my game. How do I fix this?

Hey! I'm working on a game but I'm having a problem.

In my game, there's multiple levels which are in different places in the same game, and I have to use a part to teleport the player to the next place. For some reason, it doesn't work. Please help!

The code is as follows:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local teleportPart = script.Parent
local targetPlaceID = 8493347085  -- Change this to your place ID

-- Require teleport module
local TeleportModule = require(ReplicatedStorage:WaitForChild("TeleportModule"))

local function onPartTouch(otherPart)
	-- Get player from character
	local player = Players:GetPlayerFromCharacter(otherPart.Parent)

	if player and not player:GetAttribute("Teleporting") then
		player:SetAttribute("Teleporting", true)

		-- Teleport the player
		local teleportResult = TeleportModule.teleportWithRetry(targetPlaceID, {player})

		player:SetAttribute("Teleporting", nil)
	end
end

teleportPart.Touched:Connect(onPartTouch)

2 comments

0

The best way to do this would be by teleporting the HRP to the part like this (the HumanoidRootPart is in the character) ; local hrp = {humanoidrootpart_directory} hrp.Position = {your_part}.Position

0

nvm i found something else that worked. thanks for your suggestion though!

1 answer

Maybe you should go to Game Settings, then Security, and then enable "Allow Third-Party Teleports". That should fix it.

This discussion is preserved as it was. New answers, comments, and votes are closed.