Hi DevForum users!
I am trying to send the players data through a place to a sub-place, and i am kind of confused because data changes suddenly and i am confused, and its hard to test because i need to join the main place and try testing the sub place and my internet is failing for some reasson.
Main place code:
Events.StartMatch.OnServerEvent:Connect(function(Player)
for i, lobby in shared.Lobbies do
if lobby.Owner == Player.Name then
local PlayersToTeleport = {}
local TeleportOptions = Instance.new("TeleportOptions")
local AllPlayersData = {}
for x, player in lobby.Players do
local playerInstance = Players:GetPlayerByUserId(player)
table.insert(PlayersToTeleport, playerInstance)
local Data = PlayerData.GetData(playerInstance)
table.insert(AllPlayersData, Data)
end
local TeleportData = {
lobby.Time,
lobby.MaxPlayers,
lobby.Map,
lobby.Gamemode,
AllPlayersData,
}
shared.Lobbies[i] = nil
lobby = nil
warn(lobby)
warn(TeleportData)
local ReservedServer = TeleportService:ReserveServer(108416481553178)
TeleportOptions:SetTeleportData(TeleportData)
TeleportOptions.ShouldReserveServer = true
TeleportService:TeleportAsync(108416481553178, PlayersToTeleport,TeleportOptions)
end
end
end)
Sub-place code
Players.PlayerAdded:Connect(function(player)
local joinData = player:GetJoinData()
local teleportData = joinData.TeleportData
if not Map or not Mode then
Map = teleportData[3]
Mode = teleportData[4]
end
local OwnData = GetPlayerDataInTable(teleportData[5],player.Name)
SetCharacter(player,OwnData)
player.CharacterAdded:Connect(function()
player.Character.Humanoid.WalkSpeed = 0
end)
end)