Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local ServerStorage = game:GetService("ServerStorage")
  3. local MapsFolder = ServerStorage:WaitForChild("Maps")
  4. local Status = ReplicatedStorage:WaitForChild("Status")
  5. local GameLength = 50
  6. local reward = 100
  7.  
  8. while true do
  9. Status.Value = "Wating for enough players"
  10. repeat wait(1) until game.Players.NumPlayers >= 2
  11. Status.Value = "Intermission"
  12. wait(10)
  13. local plrs = {}
  14. for i, player in pairs(game.Players:GetPlayers()) do
  15. if player then
  16. table.insert(plrs,player)
  17. end
  18. end
  19. wait(2)
  20. local AvailableMaps = MapsFolder:GetChildren()
  21. local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
  22.  
  23. Status.Value = ChosenMap.Name.." Chosen"
  24. local ClonedMap = ChosenMap:Clone()
  25. ClonedMap.Parent = workspace
  26.  
  27. local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")
  28. if not SpawnPoints then
  29. print("Spawnpoints not found")
  30. end
  31.  
  32. local AvailableSpawnPoints = SpawnPoints:GetChildren()
  33.  
  34. for i, player in pairs(plrs) do
  35. if player then
  36. character = player.Character
  37. if character then
  38. character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,10,0)
  39. table.remove(AvailableSpawnPoints,1)
  40.  
  41. local Sword = ServerStorage.Sword:Clone()
  42. Sword.Parent = player.Backpack
  43.  
  44. local GameTag = Instance.new("BoolValue")
  45. GameTag.Name = "GameTag"
  46. GameTag.Parent = player.Character
  47. else
  48. if not player then
  49. table.remove(plrs,i)
  50. end
  51. end
  52. end
  53. end
  54.  
  55. Status.Value = "Get ready to play"
  56. wait(2)
  57.  
  58.  
  59.  
  60. for i = GameLength,0,-1 do
  61. for x, player in pairs(plrs) do
  62. if player then
  63. character = player.Character
  64. if not character then
  65. --oof
  66. table.remove(plrs,x)
  67. else
  68. if character:FindFirstChild("GameTag") then
  69. print(player.Name.." is still in the game")
  70. else
  71. table.remove(plrs,x)
  72. end
  73. end
  74. end
  75. table.remove(plrs,x)
  76. print(player.Name.." has been removed")
  77. end
  78.  
  79. Status.Value = "There are "..i.." seconds remaining, and "..#plrs.." players left."
  80.  
  81. if #plrs == 1 then
  82. Status.Value = "The winner is "..plrs[1].Name
  83. plrs[1].leaderstats.Credits.Value = plrs[1].leaderstats.Credits.Value + reward
  84. break
  85. elseif #plrs == 0 then
  86. Status.Valye = "Nobody won"
  87. break
  88. elseif i == 0 then
  89. Status.Value = "Time up"
  90. break
  91. end
  92.  
  93. wait(1)
  94. end
  95.  
  96. print("End of game")
  97. wait(2)
  98. for i, player in pairs(game.Players:GetPlayers()) do
  99. character = player.Character
  100.  
  101. if not character then
  102.  
  103. else
  104. if character:FindFirstChild("GameTag") then
  105. character.GameTag:Destroy()
  106. end
  107. if player.Backpack:FindFirstChild("Sword") then
  108. player.Backpack.Sword:Destroy()
  109. end
  110.  
  111. if character:FindFirstChild("Sword") then
  112. character.Sword:Destroy()
  113. end
  114.  
  115. end
  116. player:LoadCharacter()
  117. end
  118. ClonedMap:Destroy()
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement