Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local PlayersNeeded = 2
- local RunTime = 360
- local Round = game.ReplicatedStorage.RoundInProgress
- local Map = game.ServerStorage.ActiveMap
- local Parts = Round.PartCount.Value
- local TPlayers = 0
- local function RewardPlayer(player, amount)
- if player and player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Cash") then
- player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + amount
- end
- end
- local FFC = game.FindFirstChild
- function setupMap()
- game.ReplicatedStorage.RoundInProgress.PartCount.Value = 8000
- local aMap = game.Workspace.ActiveMap
- for map, blocks in pairs (aMap.OreGeneration:GetChildren()) do
- if blocks:FindFirstChild("CubeType") and blocks.CubeType.Value == "Stone" then
- wait()
- local ran = math.random(1,15)
- if ran == 1 then
- local selOre = game.ReplicatedStorage.Ores:FindFirstChild("Ruby")
- blocks:ClearAllChildren()
- blocks.BrickColor = selOre.BrickColor
- blocks.Material = selOre.Material
- for ore,decals in pairs (selOre:GetChildren()) do
- local newDecal = decals:Clone()
- newDecal.Parent = blocks
- end
- elseif ran == 2 or ran == 3 then
- local selOre = game.ReplicatedStorage.Ores:FindFirstChild("Emerald")
- blocks:ClearAllChildren()
- blocks.BrickColor = selOre.BrickColor
- blocks.Material = selOre.Material
- for ore,decals in pairs (selOre:GetChildren()) do
- local newDecal = decals:Clone()
- newDecal.Parent = blocks
- end
- elseif ran == 4 or ran == 5 then
- local selOre = game.ReplicatedStorage.Ores:FindFirstChild("Diamond")
- blocks:ClearAllChildren()
- blocks.BrickColor = selOre.BrickColor
- blocks.Material = selOre.Material
- for ore,decals in pairs (selOre:GetChildren()) do
- local newDecal = decals:Clone()
- newDecal.Parent = blocks
- end
- elseif ran == 6 or ran == 7 or ran == 8 then
- local selOre = game.ReplicatedStorage.Ores:FindFirstChild("Gold")
- blocks:ClearAllChildren()
- blocks.BrickColor = selOre.BrickColor
- blocks.Material = selOre.Material
- for ore,decals in pairs (selOre:GetChildren()) do
- local newDecal = decals:Clone()
- newDecal.Parent = blocks
- end
- elseif ran == 9 or ran == 10 or ran == 11 or ran == 12 or ran == 13 or ran == 14 or ran == 15 then
- local selOre = game.ReplicatedStorage.Ores:FindFirstChild("Iron")
- blocks:ClearAllChildren()
- blocks.BrickColor = selOre.BrickColor
- blocks.Material = selOre.Material
- for ore,decals in pairs (selOre:GetChildren()) do
- local newDecal = decals:Clone()
- newDecal.Parent = blocks
- end
- end
- blocks.Parent = game.Workspace.ActiveMap.Blocks
- end
- end
- end
- function TagHumanoid(humanoid)
- if not humanoid:FindFirstChild("LastHitter") then
- local creator_tag = Instance.new("ObjectValue")
- creator_tag.Value = script
- creator_tag.Name = "LastHitter"
- creator_tag.Parent = humanoid
- else
- humanoid.LastHitter.Value = script
- end
- end
- function results()
- local winner = "NIL"
- local winners = {}
- local trackWinners = 0
- for i, player in ipairs(game.Players:GetChildren()) do
- if player.Character and player.Character:FindFirstChild("Torso") and player.Character:FindFirstChild("Humanoid") and player.Character:FindFirstChild("Playing") then
- if player.Character.Humanoid.Health > 0 then
- winner = player.Name
- winners[#winners+1] = player.Name
- TagHumanoid(player.Character.Humanoid)
- player.Character.Humanoid.Health = 0
- player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
- trackWinners = trackWinners + 1
- spawn(function()
- wait(.5)
- RewardPlayer(player, math.floor(30/#winners))
- end)
- end
- end
- end
- Round.Winner.Value = "Nobody"
- local sounds = game.ServerStorage.WinSounds
- local rsound = math.random(1,4)
- selsound = sounds["WinSound"..rsound]:Clone()
- selsound:Play()
- selsound.Parent = game.Workspace.ActiveMusic
- Round.Winner.Value = winner
- if winner ~= "NIL" and trackWinners == 1 then
- Round.Message.Value = "The winner is ".. winner .."!"
- elseif trackWinners > 1 then
- local winnersString = ""
- for i, winner in pairs(winners) do
- if i == 1 then
- winnersString = winner
- elseif i == # winners then
- winnersString = winnersString.." and "..winner
- else
- winnersString = winnersString..", "..winner
- end
- end
- Round.Message.Value = winnersString.." won last round!"
- else
- Round.Message.Value = "Nobody won last round!"
- end
- for _, Player in pairs(game.Players:GetChildren()) do
- local playerData = FFC(Player, "leaderstats")
- if playerData then
- if playerData.Cash.Value > 100 or playerData.Wins.Value > 1 then
- game.ReplicatedStorage.Events.MakeSystemMessage:FireClient(Player, "Be sure to leave a like if you enjoy Sky Wars!")
- end
- end
- end
- wait(4)
- end
- function checkPlayers()
- local players = game.Players:GetChildren()
- local playersInGame = 0
- for i=1,#players do
- if players[i].Character and players[i]:FindFirstChild("Loaded") then
- playersInGame = playersInGame + 1
- end
- end
- if playersInGame >= PlayersNeeded then
- return true
- else
- return false
- end
- end
- function checkRoundPlayers()
- local players = game.Players:GetChildren()
- local playersInRound = 0
- for i=1,#players do
- if players[i].Character and players[i].Character:FindFirstChild("Torso") and players[i].Character:FindFirstChild("Playing") then
- playersInRound = playersInRound + 1
- end
- end
- return playersInRound
- end
- function playSound(name)
- game.Workspace.ActiveMusic:ClearAllChildren()
- local sounds = game.ServerStorage.WinSounds
- selsound = sounds[name]:Clone()
- selsound:Play()
- selsound.Parent = game.Workspace.ActiveMusic
- end
- function giveArmor(player,id)
- if player.Character:FindFirstChild("Armor") then
- player.Character["Armor"]:Destroy()
- end
- local armor = game.ServerStorage.Items["Armor"..id]:Clone()
- for index, item in pairs (player.Character:GetChildren()) do
- if item.ClassName == "Hat" or item.ClassName == "Accessory" or item.ClassName == "CharacterMesh" then
- item:Destroy()
- end
- end
- local animation = Instance.new("Animation")
- animation.AnimationId = "http://www.roblox.com/Asset?ID=868088171"
- local animTrack = player.Character.Humanoid:LoadAnimation(animation)
- animTrack:Play()
- wait(0.5)
- armor.Parent = player.Character
- armor:SetPrimaryPartCFrame(player.Character.Torso.CFrame)
- for index, item in pairs (armor:GetChildren()) do
- if item.ClassName == "Model" then
- local bodyPart = player.Character:FindFirstChild(item.Name)
- for index, part in pairs (item:GetChildren()) do
- part.Size = part.Size + Vector3.new(0.05,0.05,0.05)
- local weld = Instance.new("Weld")
- weld.Part0 = bodyPart
- weld.Part1 = part
- weld.C0 = bodyPart.CFrame:inverse()
- weld.C1 = part.CFrame:inverse()
- weld.Parent = bodyPart
- part.Anchored = false
- end
- end
- end
- armor.Center:Destroy()
- armor.Name = "Armor"
- player.Character.Humanoid.ArmorType.Value = id
- player.Character.Humanoid.Protection.Value = armor.Protection.Value /100
- end
- local function DestroyAllTools()
- spawn(function()
- for _, child in pairs(workspace:GetChildren()) do
- if child:IsA("Tool") then
- child:Destroy()
- end
- end
- for _, player in pairs(game:GetService("Players"):GetPlayers()) do
- if player.Character then
- local tool = player.Character:FindFirstChildOfClass("Tool")
- if tool then
- tool:Destroy()
- end
- end
- for _, tool in pairs(player:WaitForChild("Backpack"):GetChildren()) do
- tool:Destroy()
- end
- end
- end)
- end
- function start()
- local Load = Map:Clone()
- Load.Parent = workspace
- wait(2)
- RunTime = 360
- Round.Message.Value = "Starting round..."
- setupMap()
- wait(2)
- Round.Message.Value = "Loading game..."
- wait(2)
- Round.Message.Value = "Get Ready!"
- TPlayers = 0
- for i, player in ipairs(game.Players:GetChildren()) do
- if player.Character and player.Character:FindFirstChild("Torso") and player:FindFirstChild("Loaded") then
- player.Character.Torso.Anchored = true
- end
- end
- wait(1)
- Round.Value = true
- wait(.5)
- Round.Winner:ClearAllChildren()
- for i, player in ipairs(game.Players:GetChildren()) do
- spawn(function()
- if player.Character and player.Character:FindFirstChild("Torso") and player:FindFirstChild("Loaded") then
- player.Character.Torso.CFrame = CFrame.new(game.Workspace.ActiveMap.Spawns:FindFirstChild(i).CFrame.p + Vector3.new(0,10,0))
- local playerResults = Instance.new("IntValue")
- playerResults.Name = player.Name
- playerResults.Parent = game.ReplicatedStorage.RoundInProgress.Winner
- playerResults.Value = 1
- local playing = Instance.new("IntValue")
- playing.Name = "Playing"
- playing.Parent = player.Character
- local inv = Instance.new("IntValue")
- inv.Name = "Inventory"
- inv.Parent = player.Character
- local wood = Instance.new("IntValue")
- wood.Name = "Wood"
- wood.Parent = inv
- local dirt = Instance.new("IntValue")
- dirt.Name = "Dirt"
- dirt.Parent = inv
- dirt.Value = 25
- local stone = Instance.new("IntValue")
- stone.Name = "Stone"
- stone.Parent = inv
- local iron = Instance.new("IntValue")
- iron.Name = "Iron"
- iron.Parent = inv
- local gold = Instance.new("IntValue")
- gold.Name = "Gold"
- gold.Parent = inv
- local diamond = Instance.new("IntValue")
- diamond.Name = "Diamond"
- diamond.Parent = inv
- local ruby = Instance.new("IntValue")
- ruby.Name = "Ruby"
- ruby.Parent = inv
- local emerald = Instance.new("IntValue")
- emerald.Name = "Emerald"
- emerald.Parent = inv
- local ptr = Instance.new("NumberValue")
- ptr.Name = "Protection"
- ptr.Parent = player.Character.Humanoid
- ptr.Value = 1
- local amr = Instance.new("NumberValue")
- amr.Name = "ArmorType"
- amr.Parent = player.Character.Humanoid
- local place = game.ServerStorage.Items["Place"]:Clone()
- place.Parent = player.Backpack
- -- Get purchased tools!
- local hasPurchasedPickaxe = false
- local hasPurchasedSword = false
- local hasPurchasedBow = false
- for _, toolType in pairs(player:WaitForChild("PurchasedTools"):GetChildren()) do
- if game.ServerStorage:WaitForChild("Items"):FindFirstChild(toolType.Value) then
- if toolType.Name == "Pickaxe" then
- hasPurchasedPickaxe = true
- elseif toolType.Name == "Sword" then
- hasPurchasedSword = true
- elseif toolType.Name == "Bow" then
- hasPurchasedBow = true
- end
- local tool = game.ServerStorage.Items[toolType.Value]:Clone()
- tool.Parent = player.Backpack
- end
- end
- if player:FindFirstChild("Package").Value == 1 then
- if not hasPurchasedPickaxe then
- local pickaxe = game.ServerStorage.Items["Obsidian Pickaxe"]:Clone()
- pickaxe.Parent = player.Backpack
- end
- if not hasPurchasedSword then
- local sword = game.ServerStorage.Items["Obsidian Sword"]:Clone()
- sword.Parent = player.Backpack
- end
- if not hasPurchasedBow then
- local bow = game.ServerStorage.Items["Obsidian bow"]:Clone()
- bow.Parent = player.Backpack
- end
- giveArmor(player,1)
- elseif player:FindFirstChild("Package").Value == 2 then
- if not hasPurchasedPickaxe then
- local pickaxe = game.ServerStorage.Items["Ruby Pickaxe"]:Clone()
- pickaxe.Parent = player.Backpack
- end
- if not hasPurchasedSword then
- local sword = game.ServerStorage.Items["Ruby Sword"]:Clone()
- sword.Parent = player.Backpack
- end
- if not hasPurchasedBow then
- local bow = game.ServerStorage.Items["Ruby bow"]:Clone()
- bow.Parent = player.Backpack
- end
- giveArmor(player,2)
- elseif player:FindFirstChild("Package").Value == 3 then
- if not hasPurchasedPickaxe then
- local pickaxe = game.ServerStorage.Items["Emerald Pickaxe"]:Clone()
- pickaxe.Parent = player.Backpack
- end
- if not hasPurchasedSword then
- local sword = game.ServerStorage.Items["Emerald Sword"]:Clone()
- sword.Parent = player.Backpack
- end
- if not hasPurchasedBow then
- local bow = game.ServerStorage.Items["Emerald bow"]:Clone()
- bow.Parent = player.Backpack
- end
- giveArmor(player,3)
- elseif player:FindFirstChild("Package").Value == 4 then
- if not hasPurchasedPickaxe then
- local pickaxe = game.ServerStorage.Items["Diamond Pickaxe"]:Clone()
- pickaxe.Parent = player.Backpack
- end
- if not hasPurchasedSword then
- local sword = game.ServerStorage.Items["Diamond Sword"]:Clone()
- sword.Parent = player.Backpack
- end
- if not hasPurchasedBow then
- local bow = game.ServerStorage.Items["Diamond bow"]:Clone()
- bow.Parent = player.Backpack
- end
- giveArmor(player,4)
- elseif player:FindFirstChild("Package").Value == 5 then
- if not hasPurchasedPickaxe then
- local pickaxe = game.ServerStorage.Items["Gold Pickaxe"]:Clone()
- pickaxe.Parent = player.Backpack
- end
- if not hasPurchasedSword then
- local sword = game.ServerStorage.Items["Gold Sword"]:Clone()
- sword.Parent = player.Backpack
- end
- if not hasPurchasedBow then
- local bow = game.ServerStorage.Items["Gold bow"]:Clone()
- bow.Parent = player.Backpack
- end
- giveArmor(player,5)
- elseif player:FindFirstChild("Package").Value == 6 then
- if not hasPurchasedPickaxe then
- local pickaxe = game.ServerStorage.Items["Iron Pickaxe"]:Clone()
- pickaxe.Parent = player.Backpack
- end
- if not hasPurchasedSword then
- local sword = game.ServerStorage.Items["Iron Sword"]:Clone()
- sword.Parent = player.Backpack
- end
- if not hasPurchasedBow then
- local bow = game.ServerStorage.Items["Iron bow"]:Clone()
- bow.Parent = player.Backpack
- end
- giveArmor(player,6)
- elseif player:FindFirstChild("Package").Value == 7 then
- if not hasPurchasedPickaxe then
- local pickaxe = game.ServerStorage.Items["Stone Pickaxe"]:Clone()
- pickaxe.Parent = player.Backpack
- end
- if not hasPurchasedSword then
- local sword = game.ServerStorage.Items["Stone Sword"]:Clone()
- sword.Parent = player.Backpack
- end
- if not hasPurchasedBow then
- local bow = game.ServerStorage.Items["Stone bow"]:Clone()
- bow.Parent = player.Backpack
- end
- giveArmor(player,7)
- else
- if not hasPurchasedPickaxe then
- local pickaxe = game.ServerStorage.Items["Wood Pickaxe"]:Clone()
- pickaxe.Parent = player.Backpack
- end
- if not hasPurchasedSword then
- local sword = game.ServerStorage.Items["Wood Sword"]:Clone()
- sword.Parent = player.Backpack
- end
- if not hasPurchasedBow then
- local bow = game.ServerStorage.Items["Wood bow"]:Clone()
- bow.Parent = player.Backpack
- end
- end
- if player.Character then
- local forceField = Instance.new("ForceField")
- forceField.Parent = player.Character
- game:GetService("Debris"):AddItem(forceField, 8)
- end
- if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 950042120) then
- local gravityCoil = game.ServerStorage.Items["Gravity coil"]:Clone()
- gravityCoil.Parent = player.Backpack
- end
- if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 950042357) then
- local speedCoil = game.ServerStorage.Items["Speed coil"]:Clone()
- speedCoil.Parent = player.Backpack
- end
- if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 950042602) then
- local epicCoil = game.ServerStorage.Items["Epic coil"]:Clone()
- epicCoil.Parent = player.Backpack
- end
- if player:FindFirstChild("Radio").Value == true then
- if player.Character ~= nil then
- if player.Character:findFirstChild("Torso") ~= nil then
- local radio = game.ServerStorage.Boombox:clone()
- radio.Parent = player.Character
- local weld = Instance.new("Weld")
- weld.Name = "BackWeld"
- weld.Part0 = player.Character:findFirstChild("Torso")
- weld.Part1 = radio
- weld.C0 = CFrame.new(0,0,1)
- weld.C0 = weld.C0 * CFrame.fromEulerAnglesXYZ(math.rad(180),math.rad(0), math.rad(180+45))
- weld.Parent = radio
- end
- end
- end
- end
- end)
- end
- wait(2)
- game.ReplicatedStorage.RoundInProgress.Time.Value = 3
- playSound("Tick3")
- wait(1)
- game.ReplicatedStorage.RoundInProgress.Time.Value = 2
- playSound("Tick2")
- wait(1)
- game.ReplicatedStorage.RoundInProgress.Time.Value = 1
- playSound("Tick1")
- wait(1)
- playSound("TickGo")
- game.ReplicatedStorage.RoundInProgress.Time.Value = 0
- for i, player in ipairs(game.Players:GetChildren()) do
- if player.Character and player.Character:FindFirstChild("Torso") and player:FindFirstChild("Loaded") then
- player.Character.Torso.Anchored = false
- TPlayers = TPlayers + 1
- end
- end
- repeat
- wait(1)
- RunTime = RunTime - 1
- Round.Message.Value = checkRoundPlayers().." players are left!"
- game.ReplicatedStorage.RoundInProgress.PlayersLeft.Value = checkRoundPlayers()
- game.ReplicatedStorage.RoundInProgress.Time.Value = RunTime
- until checkRoundPlayers() <= 1 or RunTime < 0
- Round.Value = false
- game.ReplicatedStorage.RoundInProgress.Time.Value = 0
- results()
- DestroyAllTools()
- game.Workspace.ActiveMap:Destroy()
- end
- while wait() do
- if checkPlayers() then
- start()
- t = 15
- for i=1,15 do
- Round.Message.Value = "Intermission..."
- game.ReplicatedStorage.RoundInProgress.Time.Value = t
- t=t-1
- wait(1)
- end
- game.ReplicatedStorage.RoundInProgress.Time.Value = 0
- game.Workspace.ActiveMusic:ClearAllChildren()
- else
- Round.Message.Value = "Waiting for 2 players to start..."
- game.Workspace.ActiveMusic:ClearAllChildren()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement