When someone clicks a button to make a priv server, (teleports with priv server) the server that they teleported to got “nil”
-- local script on 2nd place
local TeleportService = game:GetService("TeleportService")
local teleportData = TeleportService:GetLocalPlayerTeleportData()
print("Local player arrived with this data:", teleportData)
--output
-- Local player arrived with this data: nil
---------------------------------
-- server script on main
local teleportService = game:GetService("TeleportService")
local targetPlaceId = 129744516877103
local globaldata = game:GetService("DataStoreService"):GetDataStore("Servers")
local players = game.Players:GetPlayers()
local servers
function teleport()
local thing = Instance.new("StringValue")
thing.Name = "Server"
local AccessCode = teleportService:ReserveServer(targetPlaceId)
servers = AccessCode
local teleportdata = {
a = AccessCode
}
thing.Value = servers
thing.Parent = game.Workspace.serverkeys
globaldata:SetAsync("Servers",servers)
local teleportop = Instance.new("TeleportOptions")
local data = game:GetService("HttpService"):JSONEncode(teleportdata)
print(data)
teleportop:SetTeleportData(data)
print(teleportop:GetTeleportData())
teleportService:TeleportToPrivateServer(targetPlaceId, AccessCode, game.Players:GetPlayers(),nil,teleportop)
print(AccessCode)
end
script.Parent.MouseButton1Click:Connect(function()
teleport()
end)
-- yes httpservice is on
--also made a server script on 2nd place
game.Players.PlayerAdded:Connect(function(player)
local join = player:GetJoinData()
local thing1 = game:GetService("HttpService"):JSONDecode(join)
local teleport = thing1.TeleportData
--local thing = teleport.a
print(teleport) -- output nil
end)
--origin local script .. GUI Button
local TeleportService = game:GetService("TeleportService")
local targetPlaceId = 129744516877103
function teleportPlayers()
local accessCode = TeleportService:ReserveServer(targetPlaceId)
local teleportData = { AccessCode = accessCode }
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions:SetTeleportData(teleportData)
TeleportService:TeleportToPrivateServer(targetPlaceId, accessCode, game.Players:GetPlayers(), nil, teleportOptions)
print("Players teleported to private server with AccessCode:", accessCode)
end
script.Parent.MouseButton1Click:Connect(teleportPlayers)
--destination local script .. StarterPlayerScripts
local TeleportService = game:GetService("TeleportService")
local teleportData = TeleportService:GetLocalPlayerTeleportData()
print("Player teleport data: ", teleportData)
if teleportData then
for key, value in pairs(teleportData) do
print(key, value)
end
else
print("No teleport data.")
end
This is out of my league… I’ve done this server to server but never to a private server. Can’t say anything with certainty. If it’s getting that far then it’s being sent or read somehow wrong… I would guess.
Awesome, but be cautious when using this, i wouldn’t recommend to send important data when teleporting across places as the client has access to such data and it can be spoofed.