Advertisement
Guest User

Random Map Chooser

a guest
Apr 8th, 2020
2,791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. --[MAIN CODE IN SERVERSCRIPTSERVICE]
  2.  
  3. ServerStorage = game:GetService("ServerStorage")
  4. ReplicatedStorage = game:GetService("ReplicatedStorage")
  5. Players = game:GetService("Players")
  6.  
  7. Maps = ServerStorage:WaitForChild('Maps'):GetChildren()
  8. Status = ReplicatedStorage:WaitForChild('Status')
  9.  
  10. while true do
  11.    
  12.     --Intermission
  13.    
  14.     local Countdown = 10 -- ten second intermission, make this as long as you want
  15.    
  16.     repeat wait(1)
  17.         Countdown = Countdown - 1
  18.        
  19.         Status.Value = 'Intermission : '..Countdown
  20.     until Countdown <= 0
  21.    
  22.     --Choose the map.
  23.    
  24.     Status.Value = 'Choosing Map.'
  25.    
  26.     local ChosenMap = Maps[math.random(1, #Maps)]:Clone()
  27.     local Spawns = ChosenMap:FindFirstChild('Spawns'):GetChildren()
  28.     local RandomSpawn = Spawns[math.random(1, #Spawns)]
  29.    
  30.     wait(5) -- little pause, make this as long as you want
  31.    
  32.     ChosenMap.Parent = workspace
  33.     Status.Value = 'Map chosen, teleporting players.'
  34.    
  35.     wait(2) -- little pause, make this as long as you want
  36.    
  37.     --teleport the players
  38.    
  39.     for _, Player in pairs(Players:GetChildren())do
  40.         if Player.Character and Player.Character:FindFirstChild('Humanoid') then
  41.             Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
  42.         end
  43.     end
  44.    
  45.     Countdown = 3 -- Starting Round In, make this as long as you want
  46.    
  47.     repeat wait(1)
  48.         Countdown = Countdown - 1
  49.        
  50.         Status.Value = 'Starting Round in : '..Countdown
  51.     until Countdown <= 0
  52.    
  53.     Countdown = 10 -- Game Time, ten seconds so the video isn't long, make this as long as you want.
  54.    
  55.     repeat wait(1)
  56.         Countdown = Countdown - 1
  57.        
  58.         Status.Value = 'Ingame : '..Countdown
  59.     until Countdown <= 0
  60.    
  61.     --Kill the players
  62.    
  63.     for _, Player in pairs(Players:GetChildren())do
  64.         if Player.Character and Player.Character:FindFirstChild('Humanoid') then
  65.             Player.Character.Humanoid:TakeDamage(2000)
  66.         end
  67.     end
  68.    
  69.     ChosenMap:Destroy()
  70.    
  71.     Status.Value = 'Round Ended, waiting for new game.'
  72.    
  73.     wait(4) -- little pause, make this as long as you want.
  74.    
  75. end
  76.  
  77. --[LOCALSCRIPT IN SCREENGUI]
  78.  
  79. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  80. local Status = ReplicatedStorage:WaitForChild('Status')
  81.  
  82. local TextStatus = script.Parent.TextLabel
  83.  
  84. TextStatus.Text = Status.Value
  85.  
  86. Status.Changed:Connect(function()
  87.     TextStatus.Text = Status.Value
  88. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement