Z_Dev

Untitled

Dec 21st, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.21 KB | None | 0 0
  1. local data = workspace.Data
  2.  
  3. local boats = game.ReplicatedStorage.Ships
  4.  
  5. local spawns
  6. local weapon
  7. local healthPlayer
  8.  
  9. local players
  10.  
  11. local currentBoat = game.ReplicatedStorage.Values.CurrentBoat
  12.  
  13. -- table
  14.  
  15. local status = game.ReplicatedStorage.Values.Status -- text
  16.  
  17. local reward = 15
  18. local win = 1
  19.  
  20. for i, v in pairs(workspace.killstuff:GetChildren()) do
  21.     if v then
  22.         v.Touched:Connect(function(hit)
  23.             if hit.Parent:FindFirstChild("Humanoid") then
  24.                 hit.Parent.Humanoid:TakeDamage(100)
  25.             end
  26.         end)
  27.     end
  28. end
  29.  
  30. local function addItem()
  31.     for i, player in pairs(players) do
  32.         if player then
  33.             table.insert(player,players)
  34.         end
  35.     end
  36. end
  37.  
  38. local function timer(s)
  39.     return ("%02i:%02i"):format(s/60%60, s%60)
  40. end
  41.  
  42. local function issoldier(plr)
  43.     for _, v in pairs(players) do
  44.         if v == plr then
  45.             return true
  46.         end
  47.     end
  48.  
  49.     return false
  50. end
  51.  
  52. local function kickOut(plr)
  53.     for i, soldier in pairs(players) do
  54.         if soldier == plr then
  55.             table.remove(players,i)
  56.         end
  57.     end
  58. end
  59.  
  60. while wait(1) do
  61.     local playersTable = {}
  62.     players = playersTable
  63.     repeat wait(1) status.Value = "2 Players needed to start" until #game.Players:GetPlayers() >= 2
  64.     workspace.LobbyS.Playing = true
  65.     print("all data is ready to launch code")
  66.     for i = 10,0,-1 do
  67.         status.Value = "New round starting in "..timer(i)
  68.         wait(1)
  69.     end
  70.     wait(3)
  71.     status.Value = "loading boat..."
  72.     addItem()
  73.    
  74.     local chosenBoat = game.ReplicatedStorage.Ships:GetChildren()[math.random(1,#game.ReplicatedStorage.Ships:GetChildren())] -- choses random ship BECAUSE IM A CHAD
  75.     chosenBoat:Clone().Parent = workspace.Data -- parents it..
  76.     currentBoat.Value = chosenBoat.Name
  77.     spawns = (chosenBoat:FindFirstChild("Spawns"))
  78.     if chosenBoat then print("Our chosen boat is ".. chosenBoat.Name) end
  79.     print("boats loaded")
  80.     wait(3)
  81.     status.Value = "Teleporting players..."
  82.     players = (game.Players:GetPlayers())
  83.     for i, b in pairs(players) do
  84.         if b.Backpack:FindFirstChild("ClassicSword") then
  85.             b.Backpack.ClassicSword.SwordScript.Disabled = true
  86.         end
  87.     end
  88.     for i,v in pairs(players) do
  89.         if v then
  90.             local isDied = Instance.new("BoolValue")
  91.             isDied:Clone().Parent = v
  92.         end
  93.     end
  94.     wait(4)
  95.     workspace.LobbyS.Playing = false
  96.     for i, v in pairs(players) do
  97.         if v.Character then
  98.             v.Character:WaitForChild("HumanoidRootPart").CFrame = spawns:GetChildren()[math.random(1,#spawns:GetChildren())].CFrame + Vector3.new(0,10,0)
  99.         end
  100.     end
  101.    
  102.     workspace.Terrain.WaterWaveSpeed = 100
  103.     workspace.Terrain.WaterWaveSize = 1
  104.  
  105.     wait(3)
  106.     status.Value = "TO BATTLE!"
  107.     workspace.War.Playing = true
  108.     wait(3)
  109.     for _, plr in pairs(players) do
  110.         if plr then
  111.             game.ReplicatedStorage.Weapons.Gun:Clone().Parent = plr:WaitForChild("Backpack")
  112.             game.ReplicatedStorage.Weapons.Sword:Clone().Parent = plr:WaitForChild("Backpack")
  113.         end
  114.     end
  115.     local outcome = nil
  116.     for i = 550,0,-1 do
  117.        
  118.         warn(timer(i)) -- print(+g%)
  119.         status.Value = "Game in progress: "..timer(i)
  120.         game.Players.PlayerRemoving:Connect(function(plr)
  121.             plr.CharacterAdded:Connect(function(c)
  122.                 wait() -- empty it
  123.                 c.Humanoid:TakeDamage(100)
  124.             end)
  125.         end)
  126.         for i, b in pairs(players) do
  127.             if b.Backpack:FindFirstChild("ClassicSword") then
  128.                 b.Backpack.ClassicSword.SwordScript.Disabled = false
  129.             end
  130.         end
  131.         for i, v in pairs(players) do
  132.             if v then
  133.                 if v:FindFirstChild("Value") then
  134.                     -- make sure if player is dead
  135.                     if v.Value.Value == true then
  136.                         v.Value.Value = false
  137.                         if issoldier(v) then
  138.                             kickOut(v)
  139.                             print("player died")
  140.                             wait(.01)
  141.                             v.Value:Destroy()
  142.                         end
  143.                     end
  144.                 end
  145.             end
  146.         end
  147.        
  148.         if #players == 1 then
  149.             outcome = "AllDied"
  150.            
  151.             status.Value = "all players died!"
  152.             workspace.War.Playing = false
  153.             wait(3)
  154.             for i, v in pairs(players) do --hgiuyg.ug998gug9o vhp[-[ph[o]]
  155.                 if v then
  156.                     status.Value = "The winner is "..v.Name.."!"
  157.                     v:WaitForChild("leaderstats").Cash.Value = v:WaitForChild("leaderstats").Cash.Value + reward
  158.                     v:WaitForChild("leaderstats").Wins.Value = v:WaitForChild("leaderstats").Wins.Value + win
  159.                     wait(1)
  160.                 end
  161.             end
  162.             break
  163.         end
  164.         wait(1)
  165.     end
  166.    
  167.     for i, v in pairs(players) do
  168.         if v.Character then
  169.             v.Character.Humanoid:TakeDamage(100)
  170.         end
  171.     end    
  172.    
  173.     for i, v in pairs(players) do
  174.         if v then
  175.             if v:FindFirstChild("Value") then
  176.                 v.Value:Destroy()
  177.             end
  178.         end
  179.     end
  180.    
  181.     if outcome == "AllDied" then
  182.         print("all died")
  183.     else
  184.         status.Value = "Times up!"
  185.         for i, v in pairs(players) do
  186.             if v.Character then
  187.                 v.Character.Humanoid:TakeDamage(100);
  188.                 if issoldier(v) then
  189.                     workspace.War.Playing = false -- turn off music
  190.                     kickOut(v)
  191.                 end
  192.             end
  193.         end
  194.     end
  195.     data:ClearAllChildren()
  196.     print("data was cleared")
  197.     for i, b in pairs(players) do
  198.         if b.Backpack:FindFirstChild("ClassicSword") then
  199.             b.Backpack.ClassicSword.SwordScript.Disabled = true
  200.         end
  201.     end
  202.     for _, plr in pairs(players) do
  203.         if plr then
  204.             if issoldier(plr) then
  205.                 kickOut(plr)
  206.             end
  207.         end
  208.     end
  209.    
  210.     currentBoat.Value = "%"
  211.    
  212.     if currentBoat.Value == "%" then
  213.         warn("no boat is set!")
  214.     end
  215.    
  216.     workspace.Terrain.WaterWaveSpeed = 0
  217.     workspace.Terrain.WaterWaveSize = 0
  218.     workspace.LobbyS.Playing = true
  219.     wait(3)
  220. end
Advertisement
Add Comment
Please, Sign In to add comment