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

How can I teleport people between places in a game?

Asked by 3 years ago

So in game explorer, under places, I have 2 places. One is the main game, and one is a separate game mode. How can I make it so you can teleport between these places with a gui?

2 answers

Log in to vote
0
Answered by 3 years ago

Ok I'm incredibly new to scripting, but this is something I have achieved in my own game, so I will show you the scripts I've got and where they go.

Firstly, you need a RemoteEvent in your ReplicatedStorage for teleporting.

Then, place a script like this in the ServerScriptService:

local debounce = false

game.Workspace.TeleportPart.Touched:Connect(function(hit)
    if not debounce then
        debounce = true
        if game.Players:GetPlayerFromCharacter(hit.Parent) then
            game.ReplicatedStorage.TeleportGUI:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
        end
        wait (2)
        debounce = false
    end
end)

Then, within your GUI button, put this:

script.Parent.MouseButton1Down:Connect(function()
    game:GetService("TeleportService"):Teleport(PLACE ID HERE)
end)

Mine is set up so that the GUI is shown on a part touch, which is within part of this script.

Ad
Log in to vote
0
Answered by 3 years ago

Basically, you need to add variables and make sure the player clicks the gui:

local Variable = game:GetService("TeleportService") -- teleport service


script.Parent.MouseButton1Down:Connect(function() -- player clicking the gui

end)

then add a service thing (dunno whats it called)

local Variable = game:GetService("TeleportService")

script.Parent.MouseButton1Down:Connect(function()
        Variable:Teleport(--placeID)
end)

very simple!

Answer this question