Need help choosing random maps

So I created a system where 3 random maps from a folder are chosen and then put into choices and it worked perfectly fine but for some reason decided to break?

This script sometimes picks the same map and I don’t know how?

function addAllMaps() 
	maps = {}
	for i, map in rs.Maps:GetChildren() do
		table.insert(maps, map)
	end
	print(maps)
end

function mapVote()

	addAllMaps()
	
	print(maps)
	
	-- Choose 3 random maps that aren't the same thats not working?
	
	local randomMap1 = math.random(1, #maps)
	local mapInstance1 = maps[randomMap1]
	table.remove(maps, randomMap1)
	
	print(mapInstance1.Configuration.Title.Value)

	local randomMap2 = math.random(1, #maps)
	local mapInstance2 = maps[randomMap2]
	table.remove(maps, randomMap1)
	
	print(mapInstance2.Configuration.Title.Value)

	local randomMap3 = math.random(1, #maps)
	local mapInstance3 = maps[randomMap3]
	table.remove(maps, randomMap1)
	
	print(mapInstance3.Configuration.Title.Value)

My lord I just found the solution that I only removed randommap1 each time.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.