-- Server
local function VoteCast(player, vote)
Votes[player.UserId] = vote
GetVotes:FireAllClients(Votes)
end
-- Client
local function ChangeVotes(votes)
for i, v in pairs(votes) do
print(i, v) -- player, their Vote
end
end
GetVotes.OnClientEvent:Connect(ChangeVotes)
UI is setup like so
Choices
1
Gamemode -- Strigng Value
Votes -- TextLabel
2
Gamemode -- Strigng Value
Votes -- TextLabel
3
Gamemode -- Strigng Value
Votes -- TextLabel
So I pick 3 random gamemodes and assign them each a UI slot. Problem I now have is trying to add up those votes to show the client. Because the vote table would look like this
local function GetRandomGamemodes()
local AllGamemodes = {}
ChosenGamemodes = {}
for _, v in pairs(script:GetChildren()) do
table.insert(AllGamemodes, v.Name)
end
for i = 1, 3 do
local RandomGamemode = math.random(1, #AllGamemodes)
ChosenGamemodes[i] = AllGamemodes[RandomGamemode]
table.remove(AllGamemodes, RandomGamemode)
end
ChooseGamemode:FireAllClients(ChosenGamemodes)
end
I’m trying to grasp your concern so please bear with me if I’m not fully understanding what you’re getting at here.
After selecting all of the random game-modes for that round, I would place them all into a table and have them defined as 0, being the starter amount of votes.
I would check if the player has voted, and if they haven’t, then you’ll add them to the players table and set the fact that they’ve voted to true. You would also add a vote to the gamemodes table. If you plan on implementing vote changing, then you can simply check Voting["Players"][Player.UserId][1] == true, and if it is, then you can remove a vote from the gamemode located in the player’s table and add one for the new gamemode that they voted for.
Not sure if this is the best way of going at this, or if this solves your problem at all, but it seems reasonable enough and was one of the ways I could currently think of.