I’m working on a round system right now, basically, players will have 3 options to choose from, they will then be shown on a gui to vote (similar to Arsenal). Once voted, it creates a string value with the name of the player who voted in a folder named Votes
. Basically, I have this code here, and instead of only printing one map, it prints all of them but the output does this:
23:00:46.746 - map6 was chosen! 23:00:46.747 - map7 was chosen! (x2)
When map7 was the one I voted for. How can I fix this problem?
local selectedMaps = workspace.queuedMaps
local highestVoted
for i,vote in pairs(selectedMaps:GetChildren()) do
if not highestVoted then highestVoted = vote end
if #vote.Votes:GetChildren() > #highestVoted.Votes:GetChildren() then
2highestVoted = vote
elseif #vote.Votes:GetChildren() == #highestVoted.Votes:GetChildren() then
local mapsToChoose = {vote, highestVoted}
highestVoted = mapsToChoose[RNG:NextInteger(1, #mapsToChoose)]
end
serverClient:FireAllClients("mapChosen", highestVoted.Name)
end
If you are able to help, thank you. If not, have a great rest of your day!