Advertisement
Guest User

Work

a guest
Oct 16th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. status = game.ReplicatedStorage.Values.Status
  2. plrstowin = 1
  3. minplrs = 2
  4. intermissiontime = 30
  5. gametime = 240
  6. loadtime = 10
  7. starttime = 3
  8. money = 200
  9. mapvotetime = 20
  10. vote1 = workspace.MapVotePad1
  11. vote2 = workspace.MapVotePad2
  12. vote3 = workspace.MapVotePad3
  13. xp = 40
  14.  
  15. --game loop
  16.  
  17. while true do
  18. local won = false
  19. if #game.Players:GetPlayers() >= minplrs then
  20. --start game
  21. for i = intermissiontime,1,-1 do
  22. status.Value = "Intermission... "..i
  23. wait(1)
  24. end
  25. local maps = game.ReplicatedStorage.Maps:GetChildren()
  26. local ch1
  27. local ch2
  28. local ch3
  29. ch1 = maps[math.random(1,#maps)]
  30. repeat
  31. ch2 = maps[math.random(1,#maps)]
  32. until ch2 ~= ch1
  33. repeat
  34. ch3 = maps[math.random(1,#maps)]
  35. until ch3 ~= ch1 and ch3 ~= ch2
  36. print(ch1,ch2,ch3)
  37. vote1.Map.Value = ch1.Name
  38. vote2.Map.Value = ch2.Name
  39. vote3.Map.Value = ch3.Name
  40. vote1.Voting.Value = true
  41. vote2.Voting.Value = true
  42. vote3.Voting.Value = true
  43. for i, v in pairs(game.Players:GetChildren()) do
  44. v:WaitForChild("MapVote").Value = ""
  45. end
  46. for i = mapvotetime,1,-1 do
  47. status.Value = "Map vote... "..i
  48. wait(1)
  49. end
  50. vote1.Voting.Value = false
  51. vote2.Voting.Value = false
  52. vote3.Voting.Value = false
  53. local v1 = vote1.Votes.Value
  54. local v2 = vote2.Votes.Value
  55. local v3 = vote3.Votes.Value
  56. local chosenmap
  57. if v1 > v2 and v1 > v3 then
  58. status.Value = "The chosen map is "..vote1.Map.Value.." by "..game.ReplicatedStorage.Maps[vote1.Map.Value].Creator.Value
  59. chosenmap = vote1.Map.Value
  60. wait(2)
  61. elseif v2 > v1 and v2 > v3 then
  62. status.Value = "The chosen map is "..vote2.Map.Value.." by "..game.ReplicatedStorage.Maps[vote2.Map.Value].Creator.Value
  63. chosenmap = vote2.Map.Value
  64. wait(2)
  65. elseif v3 > v1 and v3 > v2 then
  66. status.Value = "The chosen map is "..vote3.Map.Value.." by "..game.ReplicatedStorage.Maps[vote3.Map.Value].Creator.Value
  67. chosenmap = vote3.Map.Value
  68. wait(2)
  69. else
  70. local mapss = {vote1.Map.Value,vote2.Map.Value,vote3.Map.Value}
  71. chosenmap = mapss[math.random(1,#mapss)]
  72. status.Value = "The chosen map is "..chosenmap
  73. wait(2)
  74. end
  75. for i, v in pairs(game.Players:GetChildren()) do
  76. if v:FindFirstChild("MapVote") then
  77. v.MapVote.Value = ""
  78. end
  79. end
  80. vote1.Map.Value = ""
  81. vote1.Votes.Value = 0
  82. vote2.Map.Value = ""
  83. vote2.Votes.Value = 0
  84. vote3.Map.Value = ""
  85. vote3.Votes.Value = 0
  86. local mapclone = game.ReplicatedStorage.Maps[chosenmap]:Clone()
  87. if mapclone.Name == "Si-Fi City" then
  88. game.Lighting.ClockTime = 0
  89. end
  90. mapclone.Parent = workspace
  91. for i, v in pairs(mapclone:GetChildren()) do
  92. if v:FindFirstChild("Chest") then
  93. v.Parent = workspace
  94. end
  95. end
  96. for i = loadtime,1,-1 do
  97. status.Value = "Loading map..."
  98. wait(1)
  99. end
  100. status.Value = "Starting game!"
  101. wait(starttime)
  102. game.ReplicatedStorage.Values.GameRunning.Value = true
  103. local plrs = {}
  104. for i, v in pairs(game.Players:GetPlayers()) do
  105. if v.Character then
  106. local gametag = Instance.new("StringValue",v.Character)
  107. gametag.Name = "GameTag"
  108. table.insert(plrs,v)
  109. local td = true
  110. local spawns = mapclone.Spawns:GetChildren()
  111. local chosen = spawns[math.random(1,#spawns)]
  112. v.Character:SetPrimaryPartCFrame(chosen.CFrame)
  113. v.Character.Humanoid.Died:Connect(function()
  114. if td == true then
  115. td = false
  116. if v.Character:FindFirstChild("GameTag") then
  117. v.Character.GameTag:Destroy()
  118. end
  119. end
  120. end)
  121. end
  122. end
  123. for i = gametime,1,-1 do
  124. status.Value = "Game in progress... "..i
  125. for i, v in pairs(plrs) do
  126. if v.Character then
  127. if v.Character:FindFirstChild("GameTag") then
  128.  
  129. else
  130. table.remove(plrs,i)
  131. end
  132. else
  133. table.remove(plrs,i)
  134. end
  135. end
  136. if #plrs == plrstowin then
  137. status.Value = plrs[1].Name.." is the winner!"
  138. won = true
  139. plrs[1].leaderstats["Battle Bucks"].Value = plrs[1].leaderstats["Battle Bucks"].Value + money
  140. plrs[1].XP.Value = plrs[1].XP.Value + xp
  141. plrs[1].leaderstats.Wins.Value = plrs[1].leaderstats.Wins.Value + 1
  142. wait(3)
  143. for i, v in pairs(plrs) do
  144. if v.Character then
  145. v:LoadCharacter()
  146. end
  147. end
  148. mapclone:Destroy()
  149. for i, v in pairs(workspace:GetChildren()) do
  150. if v:FindFirstChild("Chest") then
  151. v:Destroy()
  152. end
  153. end
  154. game.ReplicatedStorage.Values.GameRunning.Value = false
  155. game.Lighting.ClockTime = 14
  156. break
  157. elseif #plrs == 0 then
  158. status.Value = "No one won!"
  159. wait(3)
  160. mapclone:Destroy()
  161. for i, v in pairs(workspace:GetChildren()) do
  162. if v:FindFirstChild("Chest") then
  163. v:Destroy()
  164. end
  165. end
  166. game.ReplicatedStorage.Values.GameRunning.Value = false
  167. game.Lighting.ClockTime = 14
  168. break
  169. end
  170. wait(1)
  171. end
  172. if won == false then
  173. status.Value = "No one won!"
  174. for i, v in pairs(plrs) do
  175. if v.Character then
  176. v:LoadCharacter()
  177. end
  178. end
  179. mapclone:Destroy()
  180. for i, v in pairs(workspace:GetChildren()) do
  181. if v:FindFirstChild("Chest") then
  182. v:Destroy()
  183. end
  184. end
  185. game.ReplicatedStorage.Values.GameRunning.Value = false
  186. game.Lighting.ClockTime = 14
  187. wait(3)
  188. else
  189.  
  190. end
  191. else
  192. --display not enough players
  193. status.Value = minplrs.." or more players are required to start the game"
  194. end
  195. wait()
  196. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement