Advertisement
Guest User

dfdsf

a guest
Mar 30th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.73 KB | None | 0 0
  1. -- Define Variables
  2.  
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4.  
  5. local ServerStorage = game:GetService("ServerStorage")
  6.  
  7. local MapsFolder = ServerStorage:WaitForChild("Maps")
  8.  
  9. local Status = ReplicatedStorage:WaitForChild("Status")
  10.  
  11. local GameLength = 60
  12.  
  13. local reward = 25
  14.  
  15. local MarketplaceService = game:GetService("MarketplaceService")
  16.  
  17.  
  18. -- Game Loop
  19.  
  20. while true do
  21.  
  22. Status.Value = "Waiting for enough players."
  23.  
  24. repeat wait() until game.Players.NumPlayers >= 2
  25.  
  26. Status.Value = "Intermission"
  27.  
  28. wait(10)
  29. Status.Value = "Intermission 10"
  30. wait(1)
  31. Status.Value = "Intermission 9"
  32. wait(1)
  33. Status.Value = "Intermission 8"
  34. wait(1)
  35. Status.Value = "Intermission 7"
  36. wait(1)
  37. Status.Value = "Intermission 6"
  38. wait(1)
  39. Status.Value = "Intermission 5"
  40. wait(1)
  41. Status.Value = "Intermission 4"
  42. wait(1)
  43. Status.Value = "Intermission 3"
  44. wait(1)
  45. Status.Value = "Intermission 2"
  46. wait(1)
  47. Status.Value = "Intermission 1"
  48. wait(1)
  49. Status.Value = "Intermission 0"
  50.  
  51.  
  52. local plrs = {}
  53.  
  54. for i, player in pairs (game.Players:GetPlayers()) do
  55. if player then
  56. table.insert(plrs,player)
  57. end
  58. end
  59.  
  60. wait(2)
  61.  
  62. local AvailableMaps = MapsFolder:GetChildren()
  63.  
  64. local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
  65.  
  66. Status.Value = ChosenMap.Name.." Chosen"
  67.  
  68. local ClonedMap = ChosenMap:Clone()
  69. ClonedMap.Parent = workspace
  70.  
  71. -- Teleport Players to the map
  72.  
  73. local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")
  74.  
  75. if not SpawnPoints then
  76. print("Spawn points not found, try again!")
  77. end
  78.  
  79. local AvailableSpawnPoints = SpawnPoints:GetChildren()
  80.  
  81. for i, player in pairs(plrs) do
  82. if player then
  83. character = player.Character
  84.  
  85. if character then
  86. --teleport
  87.  
  88. wait(1.5)
  89. character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame
  90. table.remove(AvailableSpawnPoints,1)
  91.  
  92. --Give them swords
  93.  
  94. if MarketplaceService:UserOwnsGamePassAsync(player.UserId, 8685678) then
  95. local Sword = ServerStorage.Sword:Clone()
  96. Sword.Parent = player.Backpack
  97.  
  98. local Pistol = ServerStorage.Pistol:Clone()
  99. Pistol.Parent = player.Backpack
  100.  
  101. else
  102.  
  103. local Sword = ServerStorage.Sword:Clone()
  104. Sword.Parent = player.Backpack
  105.  
  106.  
  107. end
  108.  
  109. local GameTag = Instance.new("BoolValue")
  110. GameTag.Name = "Gametag"
  111. GameTag.Parent = player.Character
  112.  
  113. else
  114. --there is no character
  115. if not player then
  116. table.remove(plrs,i)
  117. end
  118.  
  119.  
  120. end
  121. end
  122. end
  123.  
  124.  
  125. Status.Value = "Get Ready to play..! The game is loading up."
  126.  
  127. wait(4)
  128.  
  129. for i = GameLength,0,-1 do
  130.  
  131. -- Retrieve the new array of players from PlayerService each iteration
  132. plrs = game.Players:GetPlayers()
  133.  
  134. for x, player in pairs(plrs) do
  135. if player then
  136.  
  137. character = player.Character
  138.  
  139. if not character then
  140. -- Left the game
  141. else
  142. if character:FindFirstChild("Gametag") then
  143. -- They are still alive
  144. print(player.Name.." Player is still in the game")
  145. else
  146. -- they are dead
  147. table.remove(plrs,x)
  148. print(player.Name.." has been removed")
  149. end
  150. end
  151. else
  152. table.remove(plrs,x)
  153. print(player.Name.." has been removed")
  154. end
  155. end
  156.  
  157. Status.Value = "There are "..i.." seconds remaining, and "..#plrs.." players left!"
  158.  
  159. if #plrs == 1 then
  160. -- last player standing
  161. Status.Value = "The winner is "..plrs[1].Name
  162. if MarketplaceService:UserOwnsGamePassAsync(plrs[1].UserId, 8642103) then
  163. plrs[1].leaderstats.Cash.Value = plrs[1].leaderstats.Cash.Value + (reward * 2)
  164. plrs[1].leaderstats.Wins.Value = plrs[1].leaderstats.Wins.Value + 1
  165. else
  166. plrs[1].leaderstats.Cash.Value = plrs[1].leaderstats.Cash.Value + reward
  167. plrs[1].leaderstats.Wins.Value = plrs[1].leaderstats.Wins.Value + 1
  168. end
  169. break
  170.  
  171. elseif #plrs == 0 then
  172. Status.Value = "Nobody won!"
  173. break
  174. elseif i == 0 then
  175. Status.Value = "Times Up!"
  176. break
  177. end
  178.  
  179. wait(1)
  180.  
  181. end
  182.  
  183. print("End of game")
  184.  
  185. for i, player in pairs(game.Players:GetPlayers())do
  186. character = player.Character
  187.  
  188. if not character then
  189. --ignore them
  190. else
  191. if character:FindFirstChild("Gametag") then
  192. character.Gametag:Destroy()
  193. end
  194.  
  195. if player.Backpack:FindFirstChild("Sword") then
  196. player.Backpack.Sword:Destroy()
  197. end
  198.  
  199. if character:FindFirstChild("Sword") then
  200. character.Sword:Destroy()
  201. end
  202.  
  203. end
  204.  
  205. player:LoadCharacter()
  206. end
  207.  
  208. ClonedMap:Destroy()
  209.  
  210. Status.Value = "Game Ended"
  211.  
  212. wait(2)
  213. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement