How to make custom ID portal?

Is it possible to make a script where a player could input a game ID and when the part is touched it would teleport them to the selected game. I have the teleportation script here. Any response is helpful!
local TeleportService = game:GetService(“TeleportService”)

local Place = IDNOTMADEYET

script.Parent.Touched:connect(function(hit)

local player = game.Players:GetPlayerFromCharacter(hit.Parent)

if player then

TeleportService:Teleport(Place, player)

end

end)

1 Like

Could you explain what exactly you need? I am not quite sure, what you want to do, and it would be nice if you formatted your code.

What I need is a explanation/help/script where a player would type a game ID into a GUI and with that, the part would teleport you to that given ID when touched.

So you want help, with making an GUI that will pass game id that player entered in textbox to the script right?

Correct. I need help with making the GUI script.

Do you want to constantly get id, or when user presses a button?

Can you define what you mean by constantly?

This is what you can do, do it in Localscript.

local Textbox = script.Parent -- Location of textbox
local DefaultId = "000000" -- Default id
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent") -- Your remote event

local function format(t) -- Make sure text contains only numbers
	return t:gsub("[^0-9.-]", "")
end

Textbox:GetPropertyChangedSignal("Text"):Connect(function()
    Textbox.Text = format(script.Parent.Text)
	if Textbox.Text ~= (nil or "") then
		Textbox.Text = tonumber(Textbox.Text)
	else
		Textbox.Text = DefaultId
	end
	RemoteEvent:FireServer(tonumber(Textbox.Text))
end)

Do this in your Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local Part = script.Parent
local TeleportService = game:GetService("TeleportService")

local Place = 000000

RemoteEvent.OnServerEvent:Connect(function(Player, Id)
	if Player and Id then
		if Id ~= "" then
			Place = tonumber(Id)
		end
	end
end)

Part.Touched:Connect(function(Hit)
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	if Player and Place then
		TeleportService:Teleport(Place, Player)
	end
end)

Let me know if it works! (Make sure to include RemoteEvent in ReplicatedStorage)
Let me know if you have any questions about the code

3 Likes

Thanks a lot for this! Helped a lot.

1 Like