Advertisement
lucas_skk

Sword game lua roblox studio

Nov 19th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.97 KB | None | 0 0
  1. --Define Variables
  2.  
  3. local ReplicatedStoroge = game:GetService("ReplicatedStorage")
  4.  
  5. local ServeStoroge = game:GetService("ServerStorage")
  6.  
  7. local MapsFolder = ServeStoroge:WaitForChild("Maps")
  8.  
  9. local Status = ReplicatedStoroge:WaitForChild("Status")
  10.  
  11. local GameLagth = 50
  12.  
  13. local reward = 25
  14.  
  15. --Game Loop
  16.  
  17. while true do
  18.    
  19.     Status.Value = "Esperando Mais Player"
  20.    
  21.     repeat wait() until game.NumPlayer >= 2
  22.    
  23.     Status.Value = "InterValo"
  24.    
  25.     wait(15)
  26.    
  27.     local plrs = {}
  28.    
  29.     for i, player in pairs(game.Players:GetService()) do
  30.         if player then
  31.             table.insert(plrs,player)
  32.         end
  33.     end
  34.    
  35.     wait(2)
  36.    
  37.     availableMaps = MapsFolder:GetChildren()
  38.      
  39.     local ChosenMap = availableMaps[math.random(1,#availableMaps)]
  40.    
  41.     Status.Value = ChosenMap.Name.. " chosen"
  42.    
  43.     local ClonedMap = ChosenMap:Clone()
  44.     ClonedMap.Parent = workspace
  45.    
  46.     --Teleport player to the map
  47.    
  48.     local SpanwPoints = ClonedMap:FindFirstChild("SpawnPoints")
  49.    
  50.     if not SpanwPoints then
  51.         print("SpanwPoint not foud!")
  52.     end
  53.    
  54.     local availableSpawnPoint = SpanwPoints:GetChildren()
  55.    
  56.     for i, player in pairs(plrs) do
  57.         if player then
  58.             character = player.character
  59.            
  60.             if not character then
  61.                 --Teleport Then
  62.                
  63.                 character:FinfFirstChild("HumanoidRootPart").Cframe = availableSpawnPoint[1].Cframe
  64.                 table.remove(availableSpawnPoint, 1)
  65.                
  66.                
  67.                 --give then sword
  68.                
  69.                 local Sword = ServeStoroge.Sword:Clone()
  70.                 Sword.Parent = player.Backpack
  71.                
  72.                 local GameTag = Instance.new("BoolValue")
  73.                 GameTag.Name = "GameTag"
  74.                 GameTag.Parent = player.character
  75.             else
  76.                 --there is to character
  77.                 if not player then
  78.                     table.remove(plrs,i)
  79.                 end
  80.             end
  81.         end
  82.     end
  83.    
  84.    
  85.      
  86.     Status.Value = "Prepare - se para jogar"
  87.    
  88.     wait(2)
  89.    
  90.     for i = GameLagth,0-1 do
  91.        
  92.         for x, player in pairs(plrs) do
  93.             if player then
  94.                
  95.                 character = player.character
  96.                
  97.                 if not character then
  98.                     --Left the game
  99.                 else
  100.                     if character:FindFirstChild("GameTag") then
  101.                         --They are still alive
  102.                         print(player.Name.."ainda está no jogo!")
  103.                     else
  104.                         --Thay Are Dead
  105.                         table.remove(plrs,x)
  106.                     end
  107.                 end
  108.             end
  109.         end
  110.        
  111.        
  112.        
  113.        
  114.        
  115.         Status.Value = "Falta segundos para acabar a partida"
  116.        
  117.         if #plrs == 1 then
  118.             --Lats Persoon listading
  119.             Status.Value = "Voçê ganhou Parabens"
  120.             plrs[1].leaderstats.Bucks.Value =   plrs[1].leaderstats.Bucks.Value + 15
  121.             plrs[1].leaderstats.Bucks.Value =   plrs[1].leaderstats.Bucks.Value + reward
  122.             break
  123.         elseif #plrs == 0 then
  124.             Status.Value = "Ninguem Uau!"
  125.             break
  126.         elseif i == 0 then
  127.             Status.Value = "Tempo esgotado"
  128.             break
  129.            
  130.         end
  131.        
  132.         wait(1)
  133.        
  134.         print("Fim de jogo")
  135.        
  136.         for i, player in pairs(game.Players:GetPlayers()) do
  137.             character = player.character
  138.            
  139.             if not character then
  140.                 --ignore then
  141.             else
  142.                 if character:FindFirstChild("GameTag") then
  143.                     character.GameTag:destory()
  144.                 end
  145.             end
  146.         end
  147.        
  148.        
  149.     end
  150.    
  151.    
  152.    
  153. end  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement