Always getting teleported to the same place

Hi, I’m making an obby game, and I need to teleport players to the obby when they choose it. I copied the ID of the place, but when I play the game, it always teleports me to the starting obby. For some reason, I solved it by putting the ID of the game it was teleporting me to, and that solved it, but now I’m getting the same problem and that doesn’t work anymore. Basically, The starting obby is called Earth World and I have another obby called Placement Test. Whenever I try to teleport to placement test, I get put in Earth world. The same thing is happening to my other obby Island. I copied the correct IDs for bolth, but I always get teleported to Earth World. What should I do?

This script runs when the player touches the portal

if game.Workspace.selrow.Value == 2 then
				if hit.slot.Value == 1 then
					game.Players.LocalPlayer.PlayerGui.levelgui.Frame.name.Text = "Island"
					game.Players.LocalPlayer.PlayerGui.levelgui.Frame.ImageLabel.Image = "http://www.roblox.com/asset/?id=9424465429"
					repeat wait()
						Camera.CameraType = Enum.CameraType.Scriptable
					until Camera.CameraType == Enum.CameraType.Scriptable
					Camera.CFrame = game.Workspace.view1.CFrame
					level = "isld"
				end
			end

And this code runs when the player presses the “Start” button

if level == "isld" then
		startbutton.Text = "Loading..."
		startbutton.BackgroundColor = BrickColor.new("Baby blue")
		print("stow")
		local teleportdata =  {
			rank = nil;
			block = 0;	
			aeb = 0
		}
		game:GetService("TeleportService"):Teleport(9437511451, game.Players.LocalPlayer, teleportdata)
	end

Thanks!

Can you put the reference script?

Yeah sure, I edited the original post to show the script

You’ve put the ID of a single place here, so they will get teleported to the same place all the time.

That script was an example of one of the scripts, a different one runs for every different obby.

The one on the top is for placement test, and the bottom is Island.

Next step is to print “level” to check what level it tp’s you to. :slight_smile:

Also to prevent a lot of if-statements for each Obby, here’s a better approach:

-- Outside your function
local Obbies = {
	["plcmt"] = 9437511451,
	["isld"] = 9492106173
}

-- Inside your function
if Obbies[level] then
	startbutton.Text = "Loading..."
	startbutton.BackgroundColor = BrickColor.new("Baby blue")
	local teleportdata =  {rank = nil;block = 0;	aeb = 0}
	game:GetService("TeleportService"):Teleport(Obbies[level], game.Players.LocalPlayer, teleportdata)
else
	warn("[SERVER]: ERROR "..level.." not found in Obbies-Table")
end

Alright, no clue what happened, but I made a line to print, and I deleted the print(“stow”) because that was an old debugging thing that I forgot to delete, and now its working.

Please go ahead and adapt your script to what I’ve posted above, since it prevents all the if-statements, that will hoard up for each new obby you make. :slight_smile:

Alright, Ill do that! Thanks for your help!

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