So the function only executes once every time a player votes but sometimes the votes just say random numbers like 3 or 0 even when nobody has voted for those maps

Events.Main.OnServerEvent:Connect(function(player,request,map,maps)
	if request == "Map" then
		print("testhh")
		if map == SelectedMaps[1].Name then
			Votes[1] = Votes[1] + 1
		elseif map == SelectedMaps[2].Name then
			Votes[2] = Votes[2] + 1
		elseif map == SelectedMaps[3].Name then
			Votes[3] = Votes[3] + 1
		end
	end
end)

function MapAPI:SelectMap(r,n,g)
	local SelMap
	print(m[1])
	for i,v in pairs(Votes) do
		if v >= Highest then
			Highest = v
			if i == 1 then
				SelMap = m[1]
			elseif i == 2 then
				SelMap = m[2]
			elseif i == 3 then
				SelMap = m[3]
			end
		end
	end
	print(string.format("%s has %d vote's!",m[1].Name,Votes[1]))
	print(string.format("%s has %d vote's!",m[2].Name,Votes[2]))
	print(string.format("%s has %d vote's!",m[3].Name,Votes[3]))
	return SelMap
end

3 comments

0

Show the rest of the script

0

yah shows us the local side please

0

did you reset the Highest after each game?