Make a GUI vote!
Make a gui in lighting named VOTER
Script in workspace:
Votes = Instance.new("Model", game.Workspace)
Votes.Name = "Votes";
function Vote()
for i,v in pairs(game.Players:GetPlayers()) do
game.Lighting.VOTER:Clone().Parent = v.PlayerGui;
end
end
if somehowthevotingtimeisready then--change this to whatever you do to check if its time to vote
Vote()
repeat wait() until #game.Workspace.Votes:GetChildren() == game.Players.NumPlayers
wins = {"","",""}--Put whatever you put in the strings HERE EXACTLY what the values are.
counts = {0,0,0}--however many indexes the table wins has
for i,v in pairs(game.Workspace.Votes:GetChildren()) do
for u, p in pairs(wins) do
if p == v.Value then
counts[u] = counts[u] + 1;
end
end
end
for j, k in pairs(counts)
if k == math.max(unpack(counts)); then
winind = math.max(unpack(counts));
WINNERMAP = wins[winind]; -- will choose the string map.
end
end
if WINNERMAP == "AMAPSNAME" then
chosenmap = game.Lighting.MAPTHATMATCHESITSNAME
end
if WINNERMAP == "AMAPSOTHERNAME" then
chosenmap = game.Lighting.MAPTHATMATCHESITSNAME
end
--And so on. so, chosenmap will be the value with the map in it.
end
ok in vote, have buttons with the maps names and or images of them.
Put a stringvalue of what the map's name is in the gui button and name is Val
Then In each button, have this code:
script.Parent.MouseButton1Click:connect(function()
script.Parent.Val:Clone().Parent = game.Workspace.Votes;
script.Parent.Parent.Parent:remove()--remove the gui. You may want to change this, incase you do not parent things or do.
--Removes so you can only vote once.
end)
I hope this all works!
|