Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- NOTES:
- if you want to use this exact script make sure there are 3 parts in workspace
- each part should be nammed Button1, Button2 and Button3
- each part should have a surfacegui with a textlabel
- you also need a folder named Maps in replicatedstorage
- put at least 3 maps there or else death
- create a model in workspace named "Structures"
- otherwise if you know what you're doing go apes**t i guess
- ]]
- Button1 = game.workspace.Button1
- Button2 = game.workspace.Button2
- Button3 = game.workspace.Button3
- --[[
- if you dont understand what this does
- its a pre-set function before the while true do
- it randomly picks the maps in the maps folder
- it keeps randomly picking the maps until all of the map variables have different map numbers
- it puts them into the table called "tablemap" and then returns the table
- which means if you use function obtainmap() it would have the value of the table
- hope this helps lmao
- ]]
- function obtainmap()
- local maps = game.ReplicatedStorage.Maps:GetChildren()
- local tablemap = {}
- local good = false -- placeholder
- repeat
- local map1 = math.random(1, #maps)
- local map2 = math.random(1, #maps)
- local map3 = math.random(1, #maps)
- if map3 ~= map2 and map2 ~= map1 and map1 ~= map3 then
- tablemap[1] = map1
- tablemap[2] = map2
- tablemap[3] = map3
- return tablemap
- end
- until good
- end
- while true do
- --voting part
- game.Workspace.Structures:ClearAllChildren() -- deletes the map at the start of the round
- --use obtainmap(), explanation above as well as get the maps
- maptable = obtainmap()
- maps = game.ReplicatedStorage.Maps:GetChildren()
- table1 = {}
- table2 = {}
- table3 = {}
- text1 = Button1.SurfaceGui.TextLabel
- text2 = Button2.SurfaceGui.TextLabel
- text3 = Button3.SurfaceGui.TextLabel
- -- changes the text of the buttons but also has the map name
- text1.Text = maps[maptable[1]].Name .. ": ".. 0
- text2.Text = maps[maptable[2]].Name .. ": ".. 0
- text3.Text = maps[maptable[3]].Name .. ": ".. 0
- voting = true
- print("start")
- Button1.Touched:Connect(function(hit)
- if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") and voting == true then
- local char = hit.Parent
- local plr = game.Players:GetPlayerFromCharacter(char)
- local tableexist = false
- if #table1 > 0 then
- for b = 1, #table1, 1 do
- if table1[b] == plr.Name then
- tableexist = true
- end
- end
- end
- if #table2 > 0 then
- for b = 1, #table2, 1 do
- if table2[b] == plr.Name then
- table.remove(table2, b)
- end
- end
- end
- if #table3 > 0 then
- for b = 1, #table3, 1 do
- if table3[b] == plr.Name then
- table.remove(table3, b)
- end
- end
- end
- if tableexist == false then
- table1[#table1 + 1] = plr.Name
- end
- text1.Text = maps[maptable[1]].Name .. ": ".. #table1
- text2.Text = maps[maptable[2]].Name .. ": ".. #table2
- text3.Text = maps[maptable[3]].Name .. ": ".. #table3
- end
- end)
- Button2.Touched:Connect(function(hit)
- if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") and voting == true then
- local char = hit.Parent
- local plr = game.Players:GetPlayerFromCharacter(char)
- local tableexist = false
- if #table2 > 0 then
- for b = 1, #table2, 1 do
- if table2[b] == plr.Name then
- tableexist = true
- end
- end
- end
- if #table1 > 0 then
- for b = 1, #table1, 1 do
- if table1[b] == plr.Name then
- table.remove(table1, b)
- end
- end
- end
- if #table3 > 0 then
- for b = 1, #table3, 1 do
- if table3[b] == plr.Name then
- table.remove(table3, b)
- end
- end
- end
- if tableexist == false then
- table2[#table2 + 1] = plr.Name
- end
- text1.Text = maps[maptable[1]].Name .. ": ".. #table1
- text2.Text = maps[maptable[2]].Name .. ": ".. #table2
- text3.Text = maps[maptable[3]].Name .. ": ".. #table3
- end
- end)
- Button3.Touched:Connect(function(hit)
- if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") and voting == true then
- local char = hit.Parent
- local plr = game.Players:GetPlayerFromCharacter(char)
- local tableexist = false
- if #table3 > 0 then
- for b = 1, #table3, 1 do
- if table3[b] == plr.Name then
- tableexist = true
- end
- end
- end
- if #table2 > 0 then
- for b = 1, #table2, 1 do
- if table2[b] == plr.Name then
- table.remove(table2, b)
- end
- end
- end
- if #table1 > 0 then
- for b = 1, #table1, 1 do
- if table1[b] == plr.Name then
- table.remove(table1, b)
- end
- end
- end
- if tableexist == false then
- table3[#table3 + 1] = plr.Name
- end
- text1.Text = maps[maptable[1]].Name .. ": ".. #table1
- text2.Text = maps[maptable[2]].Name .. ": ".. #table2
- text3.Text = maps[maptable[3]].Name .. ": ".. #table3
- end
- end)
- wait(10)
- print("table 1: " .. #table1)
- print("table 2: " .. #table2)
- print("table 3: " .. #table3)
- voting = false
- winner = 0
- values = {
- {"1", #table1};
- {"2", #table2};
- {"3", #table3};
- }
- table.sort(values, function(a, b)
- if a[2] > b[2] then
- return true
- end
- end)
- if values[1][2] <= 0 then
- winner = math.random(1, 3)
- else
- winner = tonumber(values[1][1])
- end
- -- do a specific thing for the specific vote
- b = maptable[winner] --get from the table with the winner number
- w = maps[tonumber(b)]:Clone() --clone the winning map
- w.Parent = game.Workspace.Structures -- paste into structures
- --end of voting part
- wait(5)
- --do the rest of the game
- end
Add Comment
Please, Sign In to add comment