Voting function is not working properly

So i making the sword fight game and my voting system works fine until the vote function need to start a 2 time here is the video:
robloxapp-20230122-0014111.wmv (3.6 MB)
Also here is the code of voting system:

local module = {}

local status = game.ReplicatedStorage.Values.Status

local mapVotes = {}



function getMap()
	local randomMap = game.ReplicatedStorage.Maps:GetChildren()[math.random(1,#game.ReplicatedStorage.Maps:GetChildren())]


	for i,map in pairs(mapVotes) do
		if map.name == randomMap.Name then
			return getMap()
		end
	end

	return randomMap.Name
end
local event = game.ReplicatedStorage.Events.RemoteEvent
event.OnServerEvent:Connect(function()
	game.ReplicatedStorage.Values.ISTHEVOTINGSTARTED.Value = 1
end)
	function module.MapVoting(dur)
		-- Начало голосвания,
			dur = 2
			mapVotes = {}

			for i = 1,3 do
				table.insert(mapVotes, {order = i; name = getMap(); players = {};})
			end

			game.ReplicatedStorage.Events.UpdateVotingSystem:FireAllClients(mapVotes)
			game.ReplicatedStorage.Values.VotingProgress.Value = true
	

			local placeVoteConnection = game.ReplicatedStorage.Events.PlaceVote.OnServerEvent:Connect(function(player,voteNumber)


				for i,map in pairs(mapVotes) do
					for x,plr in pairs(map.players) do
						if plr == player.UserId then
							table.remove(map.players, x)
							break
						end
					end
				end


				for i,map in pairs(mapVotes) do
					if map.order == voteNumber then
						table.insert(map.players, player.UserId)
					end
				end

			game.ReplicatedStorage.Events.UpdateVotingSystem:FireAllClients(mapVotes)
		
		end)
	
		for i = dur,0,-1 do
			if game.ReplicatedStorage.Values.VotingProgress.Value == true then
				status.Value = "You have ".. i .." "..((i==1 and "second") or "seconds").." to vote!"
				task.wait(1)
			end
		end
		
	
			if game.ReplicatedStorage.Values.Status.Value == "You have 0 seconds to vote!" then
				--Окончание голосования
				placeVoteConnection:Disconnect()

				game.ReplicatedStorage.Values.VotingProgress.Value = false

				table.sort(mapVotes, function(a,b) return #a.players > #b.players end)

				local winner

				if #mapVotes[1].players == #mapVotes[2].players and #mapVotes[2].players == #mapVotes[3].players then
					winner = mapVotes[math.random(1,3)]
				elseif #mapVotes[1].players == #mapVotes[2].players then
					winner = mapVotes[math.random(1,2)]
				else
					winner = mapVotes[1]
				end

				status.Value = winner.name.." was chosen!"
				wait(1.5)
				game.ReplicatedStorage.Values.value2.Value = 1			
				status.Value = ""
				return game.ReplicatedStorage.Maps:FindFirstChild(winner.name)			
			end	
	end
return module

Main script:

local function OnRoundEnd(player)
	local container = game.Workspace.Map.Container
	local zone2 = Zone.new(container)
	local playersremaining = zone2:getPlayers()
	print(playersremaining)
	if #playersremaining == 1 then
		EndOfTheRoundStatus.Value = "Draw"
		for _, plr in pairs(playersremaining) do			
			print(plr)
			plr.Character:MoveTo(game.Workspace.Folder.SpawnLocation.Position)
			if plr.Character:FindFirstChild("ClassicSword") and plr.Character.ClassicSword:IsA("Tool") then
				plr.Character.ClassicSword:Destroy()
			end
			if plr.Backpack:FindFirstChild("ClassicSword") then
				plr.Backpack.ClassicSword:Destroy()
			end
		end
	end
end

while true do
	if game.ReplicatedStorage.Values.ISTHEVOTINGSTARTED.Value == 1 then
		local chosenmap = voting.MapVoting()
		
		local clonedMap = chosenmap:Clone()
		print(clonedMap)
		clonedMap.Name = "Map"
		clonedMap.Parent = workspace
		
		STG.OnServerEvent:Connect(function()
			game.Workspace.gamestatus.Value = 1
		end)	
		
		game.ReplicatedStorage.Values.SomeValue.Value = 1	
		Teleporting()
		game.ReplicatedStorage.Values.TimerVisible.Value = 0
		game.ReplicatedStorage.Values.Call.Value = 1
		CFS.OnServerEvent:Connect(function(player)
			local sword2 = sword:Clone()
			sword2.Parent = player.Backpack
		end)
		
		while wait(1) do
			if game.ReplicatedStorage.Values.Call.Value == 1 then
				Timer.Value = Timer.Value - 1
			end
			if Timer.Value == 0 then
				game.ReplicatedStorage.Values.Call.Value = 0
				game.Workspace.gamestatus.Value = 0
				game.ReplicatedStorage.Values.SomeValue.Value = 0
				game.ReplicatedStorage.Values.value2.Value = 0
				game.ReplicatedStorage.Values.TimerVisible.Value = 1
				game.ReplicatedStorage.Values.ISTHEVOTINGSTARTED.Value = 0
				--print(game.ReplicatedStorage.Values.ISTHEVOTINGSTARTED.Value)
				--game.ReplicatedStorage.Values.ISTHEVOTINGENDED.Value = 0
				OnRoundEnd()	
				game.Workspace.Map:Destroy()
				Timer.Value = 8
			end	
		end
	else
		print(game.ReplicatedStorage.Values.ISTHEVOTINGSTARTED.Value)
	end
	wait(1)
end

local script:

while wait(1) do
	if game.ReplicatedStorage.Values.value2.Value == 0 then
		zone2.playerEntered:Connect(function(player)
			player.Character:MoveTo(workspace.Lobby.Spawn.Position)
		end)
	end
	local playersArray = zone3:getPlayers()
	if #playersArray == 1 and workspace.gamestatus.Value == 0 then
		print("!23")
		Event:FireServer()		
		print(game.ReplicatedStorage.Values.ISTHEVOTINGSTARTED.Value)
		STG:FireServer()
		wait(15)
	end 
end