#Help with distributing players

2 messages · Page 1 of 1 (latest)

vernal fossil
#

Gather the parts into an array using Instance:GetChildren and the players into an array using Players:GetPlayers. Iterate through the array of players, continuing onto the next iteration if their character is unavailable using the continue keyword, then select a random part from the array of parts using the following code:

local part = table.remove(parts, math.random(#parts))

Finally, use Model:PivotTo on the player's character and pass in the part's CFrame

granite forum
#

you can do

local parts = workspace.PartsFolder:GetChildren() -- example
local players = game.Players:GetPlayers()

if #players == #parts then
    for i, player in pairs(players) do
        local part = table.remove(parts, math.random(#parts))
        player.Character.HumanoidRootPart:PivotTo(part.CFrame)
    end
end

though note the number of players and parts have to be the same otherwise it wont work