How to Make Players spawn at a random Spawn

Try this;

        local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")

	if not SpawnPoints then
		print("Spawnpoints not found")
	end

	local AvailableSpawnPoints = SpawnPoints:GetChildren()

	for i, player in pairs (plrs) do
		if player then
			character = player.Character

			if character then
				-- Teleport them
                 local Pos = math.random(1,#AvailableSpawnPoints)
                 local SpawnPoint = AvailableSpawnPoints[Pos]
				character:FindFirstChild("HumanoidRootPart").CFrame = SpawnPoint.CFrame + Vector3.new(0,10,0)
				table.remove(AvailableSpawnPoints,Pos)
			end
		end
	end
8 Likes