I’m trying to make it where 1 player (randomly chosen) are teleported to one part (that’s also randomly chosen). Max players in the game are 20 players, therefore I have 20 parts all in one folder in Workspace, however, I tried to do a script but each player gets teleported onto the same part.
I know I need to add a math.random somewhere in Players, but how do I go about it? Cause I want 1 player on 1 separate part, I don’t want 2 players on the same exact spot.
local function TeleportPlayers()
local spawns = workspace.TeleportationPads:GetChildren()
local availableSpawns = {}
for i, v in pairs(spawns) do
table.insert(availableSpawns, v)
end
for i, player in pairs(game.Players:GetChildren()) do
local chosenNumber = math.random(1, #availableSpawns)
player.Character.HumanoidRootPart.Position = availableSpawns[chosenNumber].Position
table.remove(availableSpawns, chosenNumber)
end
end