Teleporting to random location rather than designated part?

Hey! I’m trying to get a TP Gui working so you can TP to the different areas of my game. It’s bubblegum sim-esque, so the different areas are stacked on top of each other in the sky and you work your way up.

I have this working, but it only works on the 1st and 2nd level. Once you get to the 3rd and beyond it no longer works.
Here’s a video showing this:
https://i.imgur.com/5MOEzBJ.mp4

The code

I have 6 layers. The TP Parts, 1-6, are all in a folder (Workspace.TeleportParts.TeleportPart#)
This code is in the main GUI Script I have that encompasses all my gui (StarterGui>Main>GUIScript)

--I cut out the code for the visuals so this is just the TP portion

layer1Button.MouseButton1Click:Connect(function()
	local player = game:GetService("Players").LocalPlayer
	local character = player.Character

	character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(teleportPart1.Position)

end)

--I just copy and paste this for each button in the TP Menu. I'm sure that's not the most efficient way to do it but it's how I got it to work lol

Right now the areas are all straight copies of each other so they should all work properly if the first one does. I did double check the teleport part anyway though and it was in the right place. Could there be a problem if the part is out of render distance or something? The 3rd layer is at y3000+.

Thanks!

The distance of the 3rd layer shouldn’t be a problem before. I have been millions of studs in the sky with rockets i’ve built in roblox studio, and you can even teleport there but it stops rendering things the same when you are millions of studs up, but 3000 studs should be fine.

I suggest that you double check the part you are teleporting it to is both anchored, and in the right spot.

1 Like

That is a very embarrassing solution :sob: I can’t believe I forgot to check that. It’s working now.

Thank you! :joy:

1 Like