I have been trying to make a TD game and I have gotten stuck on an issue with the teleportService. Basically, I need to stop it from teleporting players into games that are already in progress, or in other words, it needs to create a brand new server upon teleporting.
TeleportService:ReserveServer()
Ok thanks, I think I can figure that out on the documentation
So i’ve been trying for a while and i still can’t get it to work, it basically just won’t teleport. Here is the code I have so far:
--VARIABLES--
--Services--
local TeleportService = game:GetService("TeleportService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
--Player--
local player = Players.LocalPlayer
--Gui--
local PlayerGui = player:WaitForChild("PlayerGui")
local LoadingScreen = ReplicatedStorage:WaitForChild("LoadingGui")
local Button = script.Parent
--FUNCTIONS--
--Teleport Function--
Button.MouseButton1Click:Connect(function()
local TempLoadingGui = LoadingScreen:Clone()
TempLoadingGui.Parent = PlayerGui
local AccessCode = TeleportService:ReserveServer(ID here)
local playerList = Players:GetPlayers()
TeleportService:SetTeleportGui(TempLoadingGui)
TeleportService:TeleportToPrivateServer(ID here, AccessCode, playerList)
end)
Basically it sets the player’s GUI when you click a button and then it should teleport them, but it doesn’t.
Edit:
So basically it was in a local script and that doesn’t work
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.