im trying to clean up my game since my pc is getting potato and i want to make a teleport part with custom teleport gui since im separating some parts to different games. ive been looking through the internet for something and theres only: gui buttons and in game position teleporting, so, anyway i can achieve this?
Teleport where? Other places or a position in the game?
teleport to other places, (30 cherz)
i know its teleportservice but problem:
- what should i use to detect the touch
- i need some kind of guiding for this
You can use Region3, .Touched, or rays to detect if the part was touched, but just use .Touched as it’s way easier and not as complex as region3 or raycasting
You can use the Touched
Event’s parameter to detect if a player who touched the part is valid
local Part = script.Parent
local Debounce = false
local TPS = game:GetService("TeleportService")
local PlaceID = 00000
Part.Touched:Connect(function(Hit) --The first parameter of the touched function will always be the part that it hit
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent) --Hit.Parent is referring to the Character's Model that touched it
if Player and Debounce == false then --We're checking if we have a valid player & our debounce is false, if it is then we can teleport the player!
Debounce = true
TPS:Teleport(PlaceID, Player)
wait(10)
Debounce = false
end
end)
partially fixes my problem but what do i do to assign a custom teleport gui?
You can change the code @JackscarIitt sent to, when the part is touched, clone a gui or make a gui visible in the players PlayerGui
there are 2 problems here:
- will the gui show up TO the other game or just use the normal loading screen?
- i dont really know how to script that much so
Unless you code it to show the gui on the other game, then no
Well, looking at the API Reference it looks like the fourth parameter is your customLoadingScreen
but the third is are tuple arguments so I’m not exactly sure how to do it
Maybe something like this?
local Part = script.Parent
local Debounce = false
local TPS = game:GetService("TeleportService")
local PlaceID = 00000
local LoadingGUI = Part.LoadingGUI
Part.Touched:Connect(function(Hit) --The first parameter of the touched function will always be the part that it hit
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent) --Hit.Parent is referring to the Character's Model that touched it
if Player and Debounce == false then --We're checking if we have a valid player & our debounce is false, if it is then we can teleport the player!
local GuiClone = LoadingGui:Clone()
TeleportService:SetTeleportGui(GuiClone)
GuiClone.Parent = Player.PlayerGui
Debounce = true
TPS:Teleport(PlaceID, Player)
wait(10)
Debounce = false
end
end)
YES EXACTLY LIKE THAT
but question: will i have to insert another script into the target game?
Yeah I believe, getting the TeleportService’s GetArrivingTeleportGui
function I think it’s possible
It should look something like this I presume on a different place? (Got this from the API Reference)
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local customLoadingScreen = TeleportService:GetArrivingTeleportGui()
if customLoadingScreen then
local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
ReplicatedFirst:RemoveDefaultLoadingScreen()
customLoadingScreen.Parent = playerGui
-- animate screen here
wait(5)
-- destroy screen
customLoadingScreen:Destroy()
end
from what ive seen this is probably the solution. thanks a lot!
Just a reminder in case you forgot, but make sure to put that into a LocalScript
, preferably inside StarterGui
& Np
update: ive tested your first script and it does not work.
the gui does not show
i dont get teleported
Where exactly are you wanting to teleport from? In-game places or different separate games?
different separate games (30 cherz)