I have been trying to teleport player in a table that is in another table. The player is a string and it wants a player I’m guessing player inside game.Players but I’m not sure. I tried looping through the table but I don’t know how to look inside a table inside of a table.
Here’s my script
--//Settings//--
local placeID = 15559342116
--//Services//--
local teleportService = game:GetService("TeleportService")
--//Variables//--
local PlayerRemote = game.ReplicatedStorage.RemoteEvents.PlayerRemote
local playerToTeleport = {}
PlayerRemote.PlayerJoined.Event:Connect(function(player, chapter)
if not playerToTeleport[chapter] then
playerToTeleport[chapter] = {}
end
if not table.find(playerToTeleport[chapter], player) then
table.insert(playerToTeleport[chapter], player)
end
end)
PlayerRemote.PlayerLeft.Event:Connect(function(player, chapter)
if playerToTeleport[chapter] then
local index = table.find(playerToTeleport[chapter], player)
if index then
table.remove(playerToTeleport[chapter], index)
end
end
end)
function teleportLoop()
wait(10) --teleport delay
for chapter,player in ipairs(playerToTeleport) do
local reservedID = teleportService:ReserveServer(placeID)
teleportService:TeleportToPrivateServer(placeID, reservedID, player, nil, chapter)
end
end
teleportLoop()
I only doesn’t understand this part on how I could get the player from a table.
for chapter,player in ipairs(playerToTeleport) do
local reservedID = teleportService:ReserveServer(placeID)
teleportService:TeleportToPrivateServer(placeID, reservedID, player, nil, chapter)