Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a back-and-forth teleport GUI?

Asked by
Smoho 2
6 years ago
Edited 6 years ago

I've been attempting to make a Teleport GUI that will teleport you to the hub, then teleport you to where you've stood before then. I've gotten to the point that you can teleport to the hub, and create a saved location, but I haven't been able to get it to teleport you back to that saved location.

What I've wanted to do is this:

-When you click the button, your position is saved by placing a brick in that spot. Then, the torso's position is sent to that of a brick in the hub's.

-When you click the button a second time, your position is sent to the saved brick. The saved brick is removed.

-The third time you click, you are sent back to the hub, and a new brick is created. The process repeats from there.

The problem is, I'm not sure of how to correctly implement this. I feel like I may have gotten slightly close before, but it hasn't been working out.

Here's the script so far:

local spawnpart = workspace.TeleportPart
local playertorso = script.Parent.Parent.Parent.Parent.Character.HumanoidRootPart
local savepart = game.ReplicatedStorage.SavePart

function Click()
local savepartc = savepart:Clone()
savepartc.Position = playertorso.Position
playertorso.CFrame = CFrame.new(spawnpart.Position)
end

function Click()    
    local savepartc = workspace:WaitForChild("SavePart")
    playertorso.CFrame = CFrame.new(savepartc.Position)
    savepartc.Position = playertorso.Position
    savepartc:Remove()
end

script.Parent.MouseButton1Down:connect(Click)

EDIT: This is only one place, and it's not a teleport between multiple games. Sorry for the lack of clarification!

0
Use a datastore, and whenever the player leaves via the button, save their previous position. Then, when they rejoin the game check to see if the value stored in the datastore is empty or not. if it is not then teleport player to position. I can give you an example, if you'd like. Operation_Meme 890 — 6y
0
Oh, sorry! I suppose I haven't gone into enough detail when writing the post. The teleport isn't between different games, but multiple locations of one game. It's all at one place, but different areas in the place. Does that make more sense? Smoho 2 — 6y

Answer this question