Im trying to make a map voting GUI but it somehow turns out like this, it was working and looks perfectly when it just 1 player but it broken when it 2 players. So, I want the apearence of when it 2 Players, is the same as when it just 1 Player
When it was 1 Player:
When it was 2 Player:
Here is the codes that I used to make the Voting GUI:
- Module Script
function round.ToggleVoting()
local mapsFolder = serverStorage.Maps:GetChildren()
maps = {}
votes = {}
repeat
local map = mapsFolder[math.random(1, #mapsFolder)]
if not table.find(maps, map.Name) then
table.insert(maps, map.Name)
end
until #maps == 3
for i, map in ipairs(maps) do
votes[map] = {}
end
events.SelectingMaps:FireAllClients(maps)
info.Voting.Value = true
print(#votes)
for i = 30, 1, -1 do
info.Massage.Value = "Map Voting In Progress - "..i
wait(1)
end
local winVote = nil
local winScore = 0
for name, map in pairs(votes) do
if #map > winScore then
winVote = #map
winVote = name
end
end
if not winVote then
local n = math.random(1, #maps)
winVote = maps[n]
end
info.Voting.Value = false
print(winVote)
return winVote
end
function round.ProcessVote(player, vote)
for i, mapVotes in pairs(votes) do
local oldVote = table.find(mapVotes, player.UserId)
if oldVote then
table.remove(mapVotes, oldVote)
break
end
end
table.insert(votes[vote], player.UserId)
print(vote)
events:WaitForChild("UpdateVoteCount"):FireAllClients(votes)
end
events:WaitForChild("CastMapVote").OnServerEvent:Connect(round.ProcessVote)
- Local Script
function SetupVoteGUI()
if not info.Voting.Value then
return
end
gui.VotingFrame.Visible = true
local events = replicatedStorage:WaitForChild("Events")
local voteEvent = events:WaitForChild("CastMapVote")
local voteCountUpdate = events:WaitForChild("UpdateVoteCount")
events.SelectingMaps.OnClientEvent:Connect(function(maps)
if maps then
for i, map in pairs(maps) do
local votingButton = gui.VotingFrame.MapList.Template:Clone()
votingButton.Name = map
votingButton.Parent = gui.VotingFrame.MapList
votingButton.MapName.Text = map
votingButton.Visible = true
votingButton.Activated:Connect(function()
voteEvent:FireServer(map)
end)
end
end
end)
voteCountUpdate.OnClientEvent:Connect(function(mapScore)
for name, voteInfo in pairs(mapScore) do
print(name)
local button = gui.VotingFrame.MapList:FindFirstChild(name)
if button then
button.VoteNumber.Text = #voteInfo
end
end
end)
end
Thank You