There are 7 people on the server and each of them must be teleported to a different position.
Example:
There are 7 people on the server and each of them must be teleported to a different position.
Example:
Make Parts in random Positions and Make a BoolValue in them (or attributes or collection service if ur fancy).
Now why are we using this bool value is to ensure that only 1 player spawns per part. Now we can do a math.random sort so that each player gets a random spawn
local SpawnPoints = workspace.Folders -- that's what I expect it to be make sure all spawns with boolvalues are in there
function AllocatePlayers()
local Players = game.Players
for i,v in ipairs(Players:GetChildren()) do
local Part = v.Character.HumanoidRootPart
for i,v in ipairs(SpawnPoints:GetChildren()) do
if v.BoolValue.Value ~= false then
local Chance = math.Random(1,2)
if Chance = 1 then
Part.Position = v.Position
Part.BoolValue.Value = true
break
end
end
end)
end
local positions = {
{ 1, 0, 2 },
{ 2, 0, 1 }
}
local players = game:GetService("Players")
function beepboop()
local g = players:GetPlayers()
local length = #g
if (#positions) < length then return print(("need %s positions lol"):format(length)) end
-- amongus emergency sitting spots
local chairs = {}
local index = 0
for i, v in next, g do
index += 1
local pos = positions[index]
if not pos then continue end -- position didnt exist wow!!!!
local char = v.Character
if not char then continue end -- might be too long to wait the character
char:MoveTo(CFrame.new(table.unpack(pos[index])))
chairs[v.UserId] = pos
end
return chairs -- { [UserId] = [{x, y, z} -- array] }
end
wait(10) -- task.wait definitely not recommended
beepboop()