Hi, when the map is loaded only one player is teleporting to the map. I created a model called 'Spawns' and put in the model 2 spawn locations called 'Spawns' Here is the script
local mapsinserverstorage = game:GetService('ServerStorage'):GetChildren() -- Make sure that your maps are in serverstorage. If you have more than just maps in serverstorage, the script might actually choose that.
local chosenmap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]
chosenmap:Clone().Parent = mapstorage
status.Value = "Loading Map.."
wait(3)
local spawns = chosenmap:WaitForChild('Spawns'):GetChildren()
for _, player in pairs (game.Players:GetPlayers()) do
if player and #spawns > 0 then
local torso = player.Character:WaitForChild('HumanoidRootPart')
local allspawns = math.random(1, #spawns)
local randomspawn = spawns[allspawns]
if randomspawn and torso then
table.remove(spawns, allspawns)
torso.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0,2,0))
for i, v in pairs(player:FindFirstChild("Equipped"):GetChildren()) do
if v:IsA("Tool") then
primary = v
end
end
local newprimary = primary:Clone()
newprimary.Parent = player.Backpack
end
