here is your problem the players to teleport needs to be a table of player for example
you could have the script get players
local TS = game:GetService("TeleportService")
local code = TS:ReserveServer(4830926172)
local players = game.Players:GetPlayers()
TS:TeleportToPrivateServer(4830926172, code, PlayersToTeleport)
but if you are trying to make them teleport when touched
local part = script.Parent
local tableplayers = {}
part.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
table.Insert(tableplayers, player)
end
end)
while true do
wait(25)
TS:TeleportToPrivateServer(4830926172, code, tableplayers)
end
-- im sure this will work if it does not tell me
2 comments
You script is right, but sometime the connection can be mess up and throw some error. The solution is using pcall() https://riptutorial.com/lua/example/16000/using-pcall
I used pcall and im still getting an error. Is there possibly any other reason why this is happening?