So basically,I am making a matchmaking that should send you to the another server after there is x amount of people in the table.But when I try to teleport players from the table I get error.(Players get into the table after they click a button that fires remote event)
Argument 3 missing or nil.I don't know what should I do to fix it.
Module script:
local TS = game:GetService("TeleportService")
local isReserved = game.PrivateServerId ~= "4999054674" and
game.PrivateServerOwnerId == 131944414
players_InQueue = {}
inMatchmaking = false
module.AddPlr = function(player)
game.ReplicatedStorage.Remote.ready.OnServerEvent:Connect(function(player)
print("remote is fired")
for i = 1,#players_InQueue,1 do
if player.Name == players_InQueue[i] then
inMatchmaking = true
end
end
if inMatchmaking == false then
print("adding to table")
table.insert(players_InQueue,#players_InQueue+1,player.Name)
else
print("player is already in table")
end
for i = 1,#players_InQueue,1 do
print(players_InQueue[i])
end
inMatchmaking = false
end)
end
module.RemovePlr = function(player)
local allPlrs = game.Players:GetChildren()
for i = 1,#players_InQueue,1 do
if player.Name == players_InQueue[i] then
table.remove(players_InQueue,i)
print("Player left the game")
end
end
end
local player1 = players_InQueue[1]
module.plrTP = function(player)
while true do wait()
if #players_InQueue == 1 then
print("there is enough players for a match")
TS:TeleportToPrivateServer(game.PlaceId,isReserved,player1)
print("teleporting")
end
end
end
return module
Normal script :
local matchModule = require(script.Parent.modules.matchmaking)
game:GetService("Players").PlayerAdded:Connect(function(player)
matchModule.AddPlr(player)
matchModule.plrTP()
end)
game:GetService("Players").PlayerRemoving:Connect(function(player)
matchModule.RemovePlr(player)
end)

2 comments
What line is it on?
On line 51 in module script.