Advertisement
saturnsolar

MainScript (Map Voting GUI) | ROBLOX Studio

Apr 24th, 2020
10,711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. --torture time
  2. local rep = game:GetService("ReplicatedStorage")
  3. local mapsfolder = game:GetService("Lighting"):WaitForChild("Maps")
  4.  
  5. local booleans = rep:WaitForChild("Booleans")
  6. local variables = rep:WaitForChild("Variables")
  7. local choice1 = variables:FindFirstChild("Choice1")
  8. local choice2 = variables:FindFirstChild("Choice2")
  9. local choice3 = variables:FindFirstChild("Choice3")
  10. local winner = variables:FindFirstChild("Winner")
  11. local timer = 10 --in seconds
  12.  
  13. while true do
  14. while true do
  15.     local maps = mapsfolder:GetChildren()
  16.     choice1.Value = maps[math.random(1,#maps)]
  17.     table.remove(maps,table.find(maps,choice1.Value))
  18.     choice2.Value = maps[math.random(1,#maps)]
  19.     table.remove(maps,table.find(maps,choice2.Value))
  20.     choice3.Value = maps[math.random(1,#maps)]
  21.     table.remove(maps,table.find(maps,choice3.Value))
  22.     wait(1)
  23.     booleans:FindFirstChild("VotingSession").Value = true
  24.     wait(10)
  25.     booleans:FindFirstChild("RevealVotes").Value = true
  26.     wait(5)
  27.     booleans:FindFirstChild("VotingSession").Value = false
  28.     booleans:FindFirstChild("RevealVotes").Value = false
  29.     local chosenmap = winner.Value
  30.    
  31.     if not winner.Value then
  32.         print("Something went wrong!")
  33.         break
  34.     end
  35.     local map = chosenmap.Value
  36.     local clonemap = map:Clone()
  37.    
  38.     print("Getting map...")
  39.     wait(1)
  40.     print("Getting map spawn...")
  41.     if clonemap.Spawn then
  42.         print("Success!")
  43.     else
  44.         print("Task failed successfully")
  45.         wait()
  46.         print("Restarting...")
  47.         clonemap:Destroy()
  48.         break
  49.     end
  50.     clonemap.Parent = workspace
  51.     print("Getting players...")
  52.     local players = game:GetService("Players"):GetPlayers()
  53.     for x, player in pairs(players) do
  54.         local char = player.Character
  55.         if not char then
  56.             print(player.Name.." has no character!")
  57.         else
  58.             local humanoidrootpart = char.HumanoidRootPart
  59.             if not humanoidrootpart then
  60.                 print(player.Name.." has no HumanoidRootPart!")
  61.             else
  62.                 humanoidrootpart.CFrame = clonemap.Spawn.CFrame + Vector3.new(0,3,0)
  63.             end
  64.         end
  65.         wait()
  66.     end
  67.     for i = timer,0,-1 do
  68.         print(i)
  69.         wait(1)
  70.     end
  71.     for x, player in pairs(players) do
  72.         local char = player.Character
  73.         if not char then
  74.             print(player.Name.." has no character!")
  75.         else
  76.             local humanoidrootpart = char.HumanoidRootPart
  77.             if not humanoidrootpart then
  78.                 print(player.Name.." has no HumanoidRootPart!")
  79.             else
  80.                 humanoidrootpart.CFrame = workspace.Lobby.SpawnLocation.CFrame + Vector3.new(0,3,0)
  81.             end
  82.         end
  83.         wait()
  84.     end
  85.     clonemap:Destroy()
  86. end
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement