Voting System not working

Hello! I’m new to scripting and I was trying to make a map voting system for my game. I made the code for it and tested. It worked fine, but then I added some more code and it broke and I just can’t find a way to make it work again.
I’ve tried searching for other posts about this on the forum but I couldn’t find anything relevant.
Please let me know if you can help me!

Here’s the code that I wrote:

if votes1 > votes2 and votes1 > votes3 then -- if map 1 wins
			game.ReplicatedStorage.Maps:FindFirstChild(map1.Name):Clone().Parent = currentMapFolder
			local selectedMap = map1.Name

		elseif votes2 > votes1 and votes2 > votes3 then -- if map 2 wins
			game.ReplicatedStorage.Maps:FindFirstChild(map2.Name):Clone().Parent = currentMapFolder
			local selectedMap = map2.Name

		elseif votes3 > votes1 and votes3 > votes2 then -- if map 3 wins
			game.ReplicatedStorage.Maps:FindFirstChild(map3.Name):Clone().Parent = currentMapFolder
			local selectedMap = map3.Name

		elseif votes1 == votes2 and votes1 > votes3 then -- if theres a tie between 1 and 2
			if math.random(1, 2) == 1 then
				game.ReplicatedStorage.Maps:FindFirstChild(map1.Name):Clone().Parent = currentMapFolder
				local selectedMap = map1.Name
			else
				game.ReplicatedStorage.Maps:FindFirstChild(map2.Name):Clone().Parent = currentMapFolder
				local selectedMap = map2.Name
			end

		elseif votes2 == votes3 and votes2 > votes1 then -- if theres a tie between 2 and 3
			if math.random(1, 2) == 1 then
				game.ReplicatedStorage.Maps:FindFirstChild(map2.Name):Clone().Parent = currentMapFolder
				local selectedMap = map2.Name
			else
				game.ReplicatedStorage.Maps:FindFirstChild(map3.Name):Clone().Parent = currentMapFolder
				local selectedMap = map3.Name
			end

		elseif votes1 == votes3 and votes1 > votes2 then -- if theres a tie between 1 and 3
			if math.random(1, 2) == 1 then
				game.ReplicatedStorage.Maps:FindFirstChild(map1.Name):Clone().Parent = currentMapFolder
				local selectedMap = map1.Name
			else
				game.ReplicatedStorage.Maps:FindFirstChild(map3.Name):Clone().Parent = currentMapFolder
				local selectedMap = map3.Name
			end

		elseif (votes1 == votes2) == votes3 then -- if theres a tie between all of them
			if math.random(1, 3) == 1 then
				game.ReplicatedStorage.Maps:FindFirstChild(map1.Name):Clone().Parent = currentMapFolder
				local selectedMap = map1
			elseif math.random(1, 2) == 1 then
				game.ReplicatedStorage.Maps:FindFirstChild(map2.Name):Clone().Parent = currentMapFolder
				local selectedMap = map2.Name
			else
				game.ReplicatedStorage.Maps:FindFirstChild(map3.Name):Clone().Parent = currentMapFolder
				local selectedMap = map3.Name
			end
		end

Thanks!

3 Likes

nvm i fixed it myself.
thanks anyway i guess

1 Like