Updated on: 11/9/2023
to start creating our ui teleport button first open roblox studio and after that on the explorer tab search for "StarterGui" then create a ScreenGui together with a frame inside of it, inside the frame add a TextButton. now you will have to Insert a script into the TextButton (Its Important that you will use a local script and not a normal script / module script to make this work) and then Just copy and paste the next code into the script that you made.
local TeleportService = game:GetService("TeleportService")
local Place = 0 --//This will be the place that your player will teleport to, change this number to your place ID//--
local player = game.Players.LocalPlayer --//Here we are getting the player
what we did here was getting the teleport service which will allow us to teleport the players when they will press the button. as well as that we got the ID of the place that we want the player to teleport to.
script.Parent.MouseButton1Click:connect(function() --//This function will happen when the player will click the button//--
if Place ~= 0 then --//Checking if place ID is vaild
TeleportService:Teleport(Place, player) --//This will teleport the player into the game
end
end)
here we teleport the player Into the game we want by checking that the place ID is vaild when they click the TextButton.
full code:
local TeleportService = game:GetService("TeleportService")
local Place = 0 --//This will be the place that your player will teleport to, change this number to your place ID//--
local player = game.Players.LocalPlayer --//Here we are getting the player
script.Parent.MouseButton1Click:connect(function() --//This function will happen when the player will click the button//--
if Place ~= 0 do --//Checking if place ID is vaild//--
TeleportService:Teleport(Place, player) --//This will teleport the player into the game
end
end)
Updated on: 9/11/2023 what we will do here is that when the player will touch part he will get teleported to another place / game.
first of all go to the explorer tab and then Inside workspace create a part, after you made the part make sure that the Part is anchored so the part will no fall/move, once you do that you can copy and paste this code into the part:
local TeleportService = game:GetService("TeleportService") --//We will use this in order to make the player teleport to the other game
local Place = 0 --//This will be the place that your player will teleport to, change this number to your place ID//--
what we did here was that we got the teleport service which will let us teleport the player to the other game / place that we want him to teleport to. "local Place = 0" is the place ID that we have, you will have to change it into your Place ID in order to make it work.
script.Parent.Touched:connect(function(hit) --//When someone will tocuh this part this function will start
local player = game.Players:GetPlayerFromCharacter(hit.Parent) --Getting the player who touched the part
if player then --//Checking if player touched the part
if Place ~= 0 then --//Checking if place ID is vaild
TeleportService:Teleport(Place, player) --//Teleporting the player into the other game
end
end
end)
this part of the script will check if the player touched the part, if the player touched the part this will check if the place ID that you want the player to teleport to is vaild or not if it is vaild then the player will get teleported to the other game.
full code:
local TeleportService = game:GetService("TeleportService") --//We will use this in order to make the player teleport to the other game
local Place = 0 --//This will be the place that your player will teleport to, change this number to your place ID//--
script.Parent.Touched:connect(function(hit) --//When someone will tocuh this part this function will start
local player = game.Players:GetPlayerFromCharacter(hit.Parent) --Getting the player who touched the part
if player then --//Checking if player touched the part
if Place ~= 0 then --//Checking if place ID is vaild
TeleportService:Teleport(Place, player) --//Teleporting the player into the other game
end
end
end)