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

how can i teleport to one place then be teleported back without being in a teleport loop?

i wanna teleport to one of my other places using the TeleportService then get teleported back to the main game, but everytime i try i keep getting into a teleport loop. here is my scripts:

local teleport = game:GetService("TeleportService")
local plr = game.Players.LocalPlayer

print('Teleporting')
teleport:Teleport(Placeholder, plr, data)

script in other game:

local tp = game:GetService("TeleportService")
local player = game.Players.LocalPlayer

wait(3)
tp:Teleport(dataid, player, data2) -- Teleports them back

can someone please help me? this is my second time trying the teleportservice.

4 comments

0

make it local script

0

it is a local script

0

Yeah make it a local script, that will do the job.

0

but it is a local script and its still doing the same thing, the local script in the playergui btw

1 answer

In your first game, create a boolean called, for example local haveTeleported = false. Then, still in the first game, check to see if haveTeleported is equal to false if haveTeleported == false then and only if it is false do you set haveTeleported to true and then teleport the player.

Like this

local teleport = game:GetService("TeleportService")
local plr = game.Players.LocalPlayer
local haveTeleported = false

if haveTeleported == false then
	print('Teleporting')
	haveTeleported = true
	teleport:Teleport(Placeholder, plr, data)
end

This way when you come back you won't be teleported again. Hope this helps!

3 comments

0

it teleported me back, do i send the "haveTeleported = true" data to the other game then bring it back?

0

Oh, yes, right! Because when you leave the first game the script gets reset. I forgot about that.

0

i dont know how to properly do that yet

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