Guest User

Untitled

a guest
Jul 11th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2.  
  3. local ServerStorage = game:GetService("ServerStorage")
  4.  
  5. local MapsFolder = ServerStorage:WaitForChild("Maps")
  6.  
  7. local Status = ReplicatedStorage:WaitForChild("Status")
  8.  
  9. local GameLength = 60
  10.  
  11. local reward = 25
  12.  
  13. --Game Loop
  14.  
  15. while true do
  16.  
  17. Status.Value = "Waiting for enough players"
  18.  
  19. repeat wait (1) until game.Players.NumPlayers >= 2
  20.  
  21. Status.Value = "Intermission"
  22.  
  23. wait(5)
  24.  
  25. local plrs = {}
  26.  
  27. for i, player in pairs(game.Players:GetPlayers()) do
  28.  
  29. if player then
  30. table.insert(plrs,player)--Add each Player into plrs table
  31. end
  32. end
  33.  
  34. wait(2)
  35.  
  36. local AvailableMaps = MapsFolder:GetChildren()
  37.  
  38. local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
  39.  
  40. Status.Value = ChosenMap.Name.." Chosen"
  41.  
  42. local ClonedMap = ChosenMap:Clone()
  43. ClonedMap.Parent = workspace
  44.  
  45. --Teleport Players to the Map
  46.  
  47. local SpawnPoints = ClonedMap:FindFirstChild ("SpawnPoints")
  48.  
  49. if not SpawnPoints then
  50. print("SpawnPoint Not Found")
  51. end
  52.  
  53. local AvailableSpawnPoints = SpawnPoints:GetChildren()
  54.  
  55. for i, player in pairs(plrs)do
  56. if player then
  57. character = player.Character
  58.  
  59. if character then
  60. --teleport them
  61.  
  62. character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame
  63. table.remove(AvailableSpawnPoints,1)
  64.  
  65.  
  66. --Give them sword
  67.  
  68. local Sword = ServerStorage.Sword:Clone()
  69. Sword.Parent = player.Backpack
  70.  
  71. local Gametag = Instance.new("BoolValue")
  72. Gametag.Name = "GameTag"
  73. Gametag.Parent = player.Character
  74. else
  75. --there is no character
  76. if not player then
  77. table.remove(plrs,i)
  78. end
  79. end
  80. end
  81. end
  82.  
  83. wait (2)
  84.  
  85. Status.Value = "Get Ready To Play"
  86.  
  87. for i = GameLength,0,-1 do
  88.  
  89. for x, player in pairs(plrs) do
  90. if player then
  91. character = player.Character
  92. if not character then
  93. --left game
  94. else
  95. if character:FindFirstChild ("GameTag")then
  96. --they are alive
  97. print (player.Name.." is still the game!")
  98. else
  99. --they are dead
  100. table.remove(plrs,x)
  101. end
  102. end
  103. table.remove(plrs,x)
  104. print(player.Name.." Has Been Removed")
  105. end
  106. end
  107.  
  108. Status.Value = "There are "..i.." seconds remaining, and "..#plrs.." players left"
  109.  
  110. if #plrs == 1 then
  111. --last man standing
  112. Status.Value = "The Winner is "..plrs[1].Name
  113. plrs[1].leaderstats.chips.Value = plrs[1].leaderstats.chips.Value + reward
  114. break
  115. elseif #plrs == 0 then
  116. Status.Value = "Nobody Won"
  117. break
  118. elseif i == 0 then
  119. Status.Value = "Times Up"
  120.  
  121. end
  122.  
  123. wait(1)
  124. end
  125.  
  126. print ("End Of Game")
  127.  
  128. for i, player in pairs(game.Players:GetPlayers())do
  129. character = player.Character
  130. if not character then
  131. --Ignore them
  132. else
  133. if character:FindFirstChild("GameTag") then
  134. character.GameTag:Destroy()
  135. end
  136.  
  137. if character.Backpack:FindFirstChild("Sword")then
  138. player.Backpack.Sword:Destroy()
  139. end
  140. if character:FindFirstChild("Sword")then
  141. character.Sword:Destroy()
  142. end
  143.  
  144. end
  145.  
  146. player:LoadCharacter()
  147.  
  148. end
  149.  
  150. ClonedMap:Destroy()
  151.  
  152. Status.Value = "Game Ended"
  153.  
  154. wait(2)
  155. end
Advertisement
Add Comment
Please, Sign In to add comment