#After touching a part you get teleported to another place
1 messages · Page 1 of 1 (latest)
teleportservice
let me link the documentation rq
use this!
I have a lobby type game that will teleport you to the first stage that works perfectly but someone showed me to teleport it to a private server and it doesnt work
you need to first reserve a server
then teleport to a private server
teleportservice:reserveserver(placeid)
ill send it in two parts
you can just send it in dms
local TeleportService = game:GetService("TeleportService")
local PlayersToTeleport = {}
local ReplicatedStorage = game.ReplicatedStorage
local MinimumPlayers = 2
local MaximumPlayers = 32
function GetPlayersInQueue()
local playersinqueue = 0
for i,v in pairs(PlayersToTeleport) do
if v == nil then continue end
playersinqueue += 1
end
return playersinqueue
end
function TeleportAllPlayers()
local players = {}
local ReservedServer = TeleportService:ReserveServer(94129971080307)
for i,v in pairs(PlayersToTeleport) do
if game.Players:FindFirstChild(i) then
table.insert(players, game.Players:FindFirstChild(i))
end
end
TeleportService:TeleportToPrivateServer(94129971080307, ReservedServer, players)
PlayersToTeleport = {}
end
script.Parent.Touched:Connect(function(hit)
if GetPlayersInQueue() >= MaximumPlayers then return end
if hit.Parent:FindFirstChildOfClass("Humanoid") then
if game.Players:GetPlayerFromCharacter(hit.Parent) then
if not PlayersToTeleport[game.Players:GetPlayerFromCharacter(hit.Parent).Name] then
PlayersToTeleport[game.Players:GetPlayerFromCharacter(hit.Parent).Name] = true
ReplicatedStorage.Events.ShowLeaveButton:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
end
end
end
end)
ReplicatedStorage.Events.LeaveQueue.OnServerEvent:Connect(function(player)
if PlayersToTeleport[player.Name] then
PlayersToTeleport[player.Name] = nil
end
end)
while task.wait() do
repeat task.wait()
script.Parent.Players.TextLabel.Text = tostring(GetPlayersInQueue()).."/"..MaximumPlayers
script.Parent.Timer.TextLabel.Text = "Waiting for "..MinimumPlayers.." players!"
until GetPlayersInQueue() >= MinimumPlayers
for i = 30,0,-1 do
script.Parent.Players.TextLabel.Text = tostring(GetPlayersInQueue()).."/"..MaximumPlayers
script.Parent.Timer.TextLabel.Text = "Teleporting in "..i.." seconds!"
if GetPlayersInQueue() < MinimumPlayers then
break
end
task.wait(1)
end
if GetPlayersInQueue() >= MinimumPlayers then
TeleportAllPlayers()
end
end
game.Players.PlayerRemoving:Connect(function(player)
if PlayersToTeleport[player.Name] then
PlayersToTeleport[player.Name] = nil
end
end)
dms has the same limit
character limit i meant*
ohh
😔
right
but like a game teleporter
is there a way that there is one thats just like
simple?
kinda like a game teleporter but with a place id
function TeleportAllPlayers()
local players = {}
local ReservedServer = TeleportService:ReserveServer(94129971080307)
for i,v in pairs(PlayersToTeleport) do
if game.Players:FindFirstChild(i) then
table.insert(players, game.Players:FindFirstChild(i))
end
end
TeleportService:TeleportToPrivateServer(94129971080307, ReservedServer, players)
PlayersToTeleport = {}
end
this is the main function
the rest is just
me proofing every single scenario ever
local ReservedServer = TeleportService:ReserveServer(94129971080307)
see i reserve the server first
for i,v in pairs(PlayersToTeleport) do
if game.Players:FindFirstChild(i) then
table.insert(players, game.Players:FindFirstChild(i))
end
end
gather players into a table
TeleportService:TeleportToPrivateServer(94129971080307, ReservedServer, players)
then just teleport
mhm
alr
ill try it ot
out
so a script with this in the part?
but I need it to be after touching the part
pretty much, if youre doing solo teleports just link the function to the part
also
teleports dont work in roblox studio
i know
for i,v in pairs(PlayersToTeleport) do
if game.Players:FindFirstChild(i) then
table.insert(players, game.Players:FindFirstChild(i))
end
end
and gathering players is unnecessary if youre doing solo teleports
I wanna say I can send you the game
so you can try it out to see what im talking abou
t
im busy right now, perhaps later? for now you can attempt to create a teleport system with whatever bits of knowledge you have on teleport service
alr