Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local data = workspace.Data
- local boats = game.ReplicatedStorage.Ships
- local spawns
- local weapon
- local healthPlayer
- local players
- local currentBoat = game.ReplicatedStorage.Values.CurrentBoat
- -- table
- local status = game.ReplicatedStorage.Values.Status -- text
- local reward = 15
- local win = 1
- for i, v in pairs(workspace.killstuff:GetChildren()) do
- if v then
- v.Touched:Connect(function(hit)
- if hit.Parent:FindFirstChild("Humanoid") then
- hit.Parent.Humanoid:TakeDamage(100)
- end
- end)
- end
- end
- local function addItem()
- for i, player in pairs(players) do
- if player then
- table.insert(player,players)
- end
- end
- end
- local function timer(s)
- return ("%02i:%02i"):format(s/60%60, s%60)
- end
- local function issoldier(plr)
- for _, v in pairs(players) do
- if v == plr then
- return true
- end
- end
- return false
- end
- local function kickOut(plr)
- for i, soldier in pairs(players) do
- if soldier == plr then
- table.remove(players,i)
- end
- end
- end
- while wait(1) do
- local playersTable = {}
- players = playersTable
- repeat wait(1) status.Value = "2 Players needed to start" until #game.Players:GetPlayers() >= 2
- workspace.LobbyS.Playing = true
- print("all data is ready to launch code")
- for i = 10,0,-1 do
- status.Value = "New round starting in "..timer(i)
- wait(1)
- end
- wait(3)
- status.Value = "loading boat..."
- addItem()
- local chosenBoat = game.ReplicatedStorage.Ships:GetChildren()[math.random(1,#game.ReplicatedStorage.Ships:GetChildren())] -- choses random ship BECAUSE IM A CHAD
- chosenBoat:Clone().Parent = workspace.Data -- parents it..
- currentBoat.Value = chosenBoat.Name
- spawns = (chosenBoat:FindFirstChild("Spawns"))
- if chosenBoat then print("Our chosen boat is ".. chosenBoat.Name) end
- print("boats loaded")
- wait(3)
- status.Value = "Teleporting players..."
- players = (game.Players:GetPlayers())
- for i, b in pairs(players) do
- if b.Backpack:FindFirstChild("ClassicSword") then
- b.Backpack.ClassicSword.SwordScript.Disabled = true
- end
- end
- for i,v in pairs(players) do
- if v then
- local isDied = Instance.new("BoolValue")
- isDied:Clone().Parent = v
- end
- end
- wait(4)
- workspace.LobbyS.Playing = false
- for i, v in pairs(players) do
- if v.Character then
- v.Character:WaitForChild("HumanoidRootPart").CFrame = spawns:GetChildren()[math.random(1,#spawns:GetChildren())].CFrame + Vector3.new(0,10,0)
- end
- end
- workspace.Terrain.WaterWaveSpeed = 100
- workspace.Terrain.WaterWaveSize = 1
- wait(3)
- status.Value = "TO BATTLE!"
- workspace.War.Playing = true
- wait(3)
- for _, plr in pairs(players) do
- if plr then
- game.ReplicatedStorage.Weapons.Gun:Clone().Parent = plr:WaitForChild("Backpack")
- game.ReplicatedStorage.Weapons.Sword:Clone().Parent = plr:WaitForChild("Backpack")
- end
- end
- local outcome = nil
- for i = 550,0,-1 do
- warn(timer(i)) -- print(+g%)
- status.Value = "Game in progress: "..timer(i)
- game.Players.PlayerRemoving:Connect(function(plr)
- plr.CharacterAdded:Connect(function(c)
- wait() -- empty it
- c.Humanoid:TakeDamage(100)
- end)
- end)
- for i, b in pairs(players) do
- if b.Backpack:FindFirstChild("ClassicSword") then
- b.Backpack.ClassicSword.SwordScript.Disabled = false
- end
- end
- for i, v in pairs(players) do
- if v then
- if v:FindFirstChild("Value") then
- -- make sure if player is dead
- if v.Value.Value == true then
- v.Value.Value = false
- if issoldier(v) then
- kickOut(v)
- print("player died")
- wait(.01)
- v.Value:Destroy()
- end
- end
- end
- end
- end
- if #players == 1 then
- outcome = "AllDied"
- status.Value = "all players died!"
- workspace.War.Playing = false
- wait(3)
- for i, v in pairs(players) do --hgiuyg.ug998gug9o vhp[-[ph[o]]
- if v then
- status.Value = "The winner is "..v.Name.."!"
- v:WaitForChild("leaderstats").Cash.Value = v:WaitForChild("leaderstats").Cash.Value + reward
- v:WaitForChild("leaderstats").Wins.Value = v:WaitForChild("leaderstats").Wins.Value + win
- wait(1)
- end
- end
- break
- end
- wait(1)
- end
- for i, v in pairs(players) do
- if v.Character then
- v.Character.Humanoid:TakeDamage(100)
- end
- end
- for i, v in pairs(players) do
- if v then
- if v:FindFirstChild("Value") then
- v.Value:Destroy()
- end
- end
- end
- if outcome == "AllDied" then
- print("all died")
- else
- status.Value = "Times up!"
- for i, v in pairs(players) do
- if v.Character then
- v.Character.Humanoid:TakeDamage(100);
- if issoldier(v) then
- workspace.War.Playing = false -- turn off music
- kickOut(v)
- end
- end
- end
- end
- data:ClearAllChildren()
- print("data was cleared")
- for i, b in pairs(players) do
- if b.Backpack:FindFirstChild("ClassicSword") then
- b.Backpack.ClassicSword.SwordScript.Disabled = true
- end
- end
- for _, plr in pairs(players) do
- if plr then
- if issoldier(plr) then
- kickOut(plr)
- end
- end
- end
- currentBoat.Value = "%"
- if currentBoat.Value == "%" then
- warn("no boat is set!")
- end
- workspace.Terrain.WaterWaveSpeed = 0
- workspace.Terrain.WaterWaveSize = 0
- workspace.LobbyS.Playing = true
- wait(3)
- end
Advertisement
Add Comment
Please, Sign In to add comment