Advertisement
ryanschrader020105

Untitled

Jun 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.02 KB | None | 0 0
  1. local PlayersNeeded = 2
  2. local RunTime = 360
  3. local Round = game.ReplicatedStorage.RoundInProgress
  4. local Map = game.ServerStorage.ActiveMap
  5. local Parts = Round.PartCount.Value
  6.  
  7. local TPlayers = 0
  8.  
  9. local function RewardPlayer(player, amount)
  10. if player and player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Cash") then
  11. player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + amount
  12. end
  13. end
  14.  
  15. local FFC = game.FindFirstChild
  16.  
  17. function setupMap()
  18. game.ReplicatedStorage.RoundInProgress.PartCount.Value = 8000
  19. local aMap = game.Workspace.ActiveMap
  20. for map, blocks in pairs (aMap.OreGeneration:GetChildren()) do
  21. if blocks:FindFirstChild("CubeType") and blocks.CubeType.Value == "Stone" then
  22. wait()
  23. local ran = math.random(1,15)
  24. if ran == 1 then
  25. local selOre = game.ReplicatedStorage.Ores:FindFirstChild("Ruby")
  26. blocks:ClearAllChildren()
  27. blocks.BrickColor = selOre.BrickColor
  28. blocks.Material = selOre.Material
  29. for ore,decals in pairs (selOre:GetChildren()) do
  30. local newDecal = decals:Clone()
  31. newDecal.Parent = blocks
  32. end
  33. elseif ran == 2 or ran == 3 then
  34. local selOre = game.ReplicatedStorage.Ores:FindFirstChild("Emerald")
  35. blocks:ClearAllChildren()
  36. blocks.BrickColor = selOre.BrickColor
  37. blocks.Material = selOre.Material
  38. for ore,decals in pairs (selOre:GetChildren()) do
  39. local newDecal = decals:Clone()
  40. newDecal.Parent = blocks
  41. end
  42. elseif ran == 4 or ran == 5 then
  43. local selOre = game.ReplicatedStorage.Ores:FindFirstChild("Diamond")
  44. blocks:ClearAllChildren()
  45. blocks.BrickColor = selOre.BrickColor
  46. blocks.Material = selOre.Material
  47. for ore,decals in pairs (selOre:GetChildren()) do
  48. local newDecal = decals:Clone()
  49. newDecal.Parent = blocks
  50. end
  51. elseif ran == 6 or ran == 7 or ran == 8 then
  52. local selOre = game.ReplicatedStorage.Ores:FindFirstChild("Gold")
  53. blocks:ClearAllChildren()
  54. blocks.BrickColor = selOre.BrickColor
  55. blocks.Material = selOre.Material
  56. for ore,decals in pairs (selOre:GetChildren()) do
  57. local newDecal = decals:Clone()
  58. newDecal.Parent = blocks
  59. end
  60. elseif ran == 9 or ran == 10 or ran == 11 or ran == 12 or ran == 13 or ran == 14 or ran == 15 then
  61. local selOre = game.ReplicatedStorage.Ores:FindFirstChild("Iron")
  62. blocks:ClearAllChildren()
  63. blocks.BrickColor = selOre.BrickColor
  64. blocks.Material = selOre.Material
  65. for ore,decals in pairs (selOre:GetChildren()) do
  66. local newDecal = decals:Clone()
  67. newDecal.Parent = blocks
  68. end
  69. end
  70. blocks.Parent = game.Workspace.ActiveMap.Blocks
  71. end
  72. end
  73. end
  74.  
  75. function TagHumanoid(humanoid)
  76. if not humanoid:FindFirstChild("LastHitter") then
  77. local creator_tag = Instance.new("ObjectValue")
  78. creator_tag.Value = script
  79. creator_tag.Name = "LastHitter"
  80. creator_tag.Parent = humanoid
  81. else
  82. humanoid.LastHitter.Value = script
  83. end
  84. end
  85.  
  86. function results()
  87. local winner = "NIL"
  88. local winners = {}
  89. local trackWinners = 0
  90. for i, player in ipairs(game.Players:GetChildren()) do
  91. if player.Character and player.Character:FindFirstChild("Torso") and player.Character:FindFirstChild("Humanoid") and player.Character:FindFirstChild("Playing") then
  92. if player.Character.Humanoid.Health > 0 then
  93. winner = player.Name
  94. winners[#winners+1] = player.Name
  95. TagHumanoid(player.Character.Humanoid)
  96. player.Character.Humanoid.Health = 0
  97. player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
  98. trackWinners = trackWinners + 1
  99. spawn(function()
  100. wait(.5)
  101. RewardPlayer(player, math.floor(30/#winners))
  102. end)
  103. end
  104. end
  105. end
  106. Round.Winner.Value = "Nobody"
  107. local sounds = game.ServerStorage.WinSounds
  108. local rsound = math.random(1,4)
  109. selsound = sounds["WinSound"..rsound]:Clone()
  110. selsound:Play()
  111. selsound.Parent = game.Workspace.ActiveMusic
  112. Round.Winner.Value = winner
  113. if winner ~= "NIL" and trackWinners == 1 then
  114. Round.Message.Value = "The winner is ".. winner .."!"
  115. elseif trackWinners > 1 then
  116. local winnersString = ""
  117. for i, winner in pairs(winners) do
  118. if i == 1 then
  119. winnersString = winner
  120. elseif i == # winners then
  121. winnersString = winnersString.." and "..winner
  122. else
  123. winnersString = winnersString..", "..winner
  124. end
  125. end
  126. Round.Message.Value = winnersString.." won last round!"
  127. else
  128. Round.Message.Value = "Nobody won last round!"
  129. end
  130. for _, Player in pairs(game.Players:GetChildren()) do
  131. local playerData = FFC(Player, "leaderstats")
  132. if playerData then
  133. if playerData.Cash.Value > 100 or playerData.Wins.Value > 1 then
  134. game.ReplicatedStorage.Events.MakeSystemMessage:FireClient(Player, "Be sure to leave a like if you enjoy Sky Wars!")
  135. end
  136. end
  137. end
  138. wait(4)
  139. end
  140.  
  141. function checkPlayers()
  142. local players = game.Players:GetChildren()
  143. local playersInGame = 0
  144. for i=1,#players do
  145. if players[i].Character and players[i]:FindFirstChild("Loaded") then
  146. playersInGame = playersInGame + 1
  147. end
  148. end
  149. if playersInGame >= PlayersNeeded then
  150. return true
  151. else
  152. return false
  153. end
  154. end
  155.  
  156. function checkRoundPlayers()
  157. local players = game.Players:GetChildren()
  158. local playersInRound = 0
  159. for i=1,#players do
  160. if players[i].Character and players[i].Character:FindFirstChild("Torso") and players[i].Character:FindFirstChild("Playing") then
  161. playersInRound = playersInRound + 1
  162. end
  163. end
  164. return playersInRound
  165. end
  166.  
  167. function playSound(name)
  168. game.Workspace.ActiveMusic:ClearAllChildren()
  169. local sounds = game.ServerStorage.WinSounds
  170. selsound = sounds[name]:Clone()
  171. selsound:Play()
  172. selsound.Parent = game.Workspace.ActiveMusic
  173. end
  174.  
  175. function giveArmor(player,id)
  176. if player.Character:FindFirstChild("Armor") then
  177. player.Character["Armor"]:Destroy()
  178. end
  179. local armor = game.ServerStorage.Items["Armor"..id]:Clone()
  180. for index, item in pairs (player.Character:GetChildren()) do
  181. if item.ClassName == "Hat" or item.ClassName == "Accessory" or item.ClassName == "CharacterMesh" then
  182. item:Destroy()
  183. end
  184. end
  185. local animation = Instance.new("Animation")
  186. animation.AnimationId = "http://www.roblox.com/Asset?ID=868088171"
  187. local animTrack = player.Character.Humanoid:LoadAnimation(animation)
  188. animTrack:Play()
  189. wait(0.5)
  190. armor.Parent = player.Character
  191. armor:SetPrimaryPartCFrame(player.Character.Torso.CFrame)
  192. for index, item in pairs (armor:GetChildren()) do
  193. if item.ClassName == "Model" then
  194. local bodyPart = player.Character:FindFirstChild(item.Name)
  195. for index, part in pairs (item:GetChildren()) do
  196. part.Size = part.Size + Vector3.new(0.05,0.05,0.05)
  197. local weld = Instance.new("Weld")
  198. weld.Part0 = bodyPart
  199. weld.Part1 = part
  200. weld.C0 = bodyPart.CFrame:inverse()
  201. weld.C1 = part.CFrame:inverse()
  202. weld.Parent = bodyPart
  203. part.Anchored = false
  204. end
  205. end
  206. end
  207.  
  208. armor.Center:Destroy()
  209. armor.Name = "Armor"
  210. player.Character.Humanoid.ArmorType.Value = id
  211. player.Character.Humanoid.Protection.Value = armor.Protection.Value /100
  212. end
  213.  
  214. local function DestroyAllTools()
  215. spawn(function()
  216. for _, child in pairs(workspace:GetChildren()) do
  217. if child:IsA("Tool") then
  218. child:Destroy()
  219. end
  220. end
  221. for _, player in pairs(game:GetService("Players"):GetPlayers()) do
  222. if player.Character then
  223. local tool = player.Character:FindFirstChildOfClass("Tool")
  224. if tool then
  225. tool:Destroy()
  226. end
  227. end
  228. for _, tool in pairs(player:WaitForChild("Backpack"):GetChildren()) do
  229. tool:Destroy()
  230. end
  231. end
  232. end)
  233. end
  234.  
  235. function start()
  236. local Load = Map:Clone()
  237. Load.Parent = workspace
  238. wait(2)
  239. RunTime = 360
  240. Round.Message.Value = "Starting round..."
  241. setupMap()
  242. wait(2)
  243. Round.Message.Value = "Loading game..."
  244. wait(2)
  245. Round.Message.Value = "Get Ready!"
  246. TPlayers = 0
  247. for i, player in ipairs(game.Players:GetChildren()) do
  248. if player.Character and player.Character:FindFirstChild("Torso") and player:FindFirstChild("Loaded") then
  249. player.Character.Torso.Anchored = true
  250. end
  251. end
  252. wait(1)
  253. Round.Value = true
  254. wait(.5)
  255. Round.Winner:ClearAllChildren()
  256. for i, player in ipairs(game.Players:GetChildren()) do
  257. spawn(function()
  258. if player.Character and player.Character:FindFirstChild("Torso") and player:FindFirstChild("Loaded") then
  259. player.Character.Torso.CFrame = CFrame.new(game.Workspace.ActiveMap.Spawns:FindFirstChild(i).CFrame.p + Vector3.new(0,10,0))
  260.  
  261. local playerResults = Instance.new("IntValue")
  262. playerResults.Name = player.Name
  263. playerResults.Parent = game.ReplicatedStorage.RoundInProgress.Winner
  264. playerResults.Value = 1
  265.  
  266. local playing = Instance.new("IntValue")
  267. playing.Name = "Playing"
  268. playing.Parent = player.Character
  269.  
  270. local inv = Instance.new("IntValue")
  271. inv.Name = "Inventory"
  272. inv.Parent = player.Character
  273.  
  274. local wood = Instance.new("IntValue")
  275. wood.Name = "Wood"
  276. wood.Parent = inv
  277.  
  278. local dirt = Instance.new("IntValue")
  279. dirt.Name = "Dirt"
  280. dirt.Parent = inv
  281. dirt.Value = 25
  282.  
  283. local stone = Instance.new("IntValue")
  284. stone.Name = "Stone"
  285. stone.Parent = inv
  286.  
  287. local iron = Instance.new("IntValue")
  288. iron.Name = "Iron"
  289. iron.Parent = inv
  290.  
  291. local gold = Instance.new("IntValue")
  292. gold.Name = "Gold"
  293. gold.Parent = inv
  294.  
  295. local diamond = Instance.new("IntValue")
  296. diamond.Name = "Diamond"
  297. diamond.Parent = inv
  298.  
  299. local ruby = Instance.new("IntValue")
  300. ruby.Name = "Ruby"
  301. ruby.Parent = inv
  302.  
  303. local emerald = Instance.new("IntValue")
  304. emerald.Name = "Emerald"
  305. emerald.Parent = inv
  306.  
  307. local ptr = Instance.new("NumberValue")
  308. ptr.Name = "Protection"
  309. ptr.Parent = player.Character.Humanoid
  310. ptr.Value = 1
  311.  
  312. local amr = Instance.new("NumberValue")
  313. amr.Name = "ArmorType"
  314. amr.Parent = player.Character.Humanoid
  315.  
  316. local place = game.ServerStorage.Items["Place"]:Clone()
  317. place.Parent = player.Backpack
  318.  
  319. -- Get purchased tools!
  320. local hasPurchasedPickaxe = false
  321. local hasPurchasedSword = false
  322. local hasPurchasedBow = false
  323.  
  324. for _, toolType in pairs(player:WaitForChild("PurchasedTools"):GetChildren()) do
  325. if game.ServerStorage:WaitForChild("Items"):FindFirstChild(toolType.Value) then
  326. if toolType.Name == "Pickaxe" then
  327. hasPurchasedPickaxe = true
  328. elseif toolType.Name == "Sword" then
  329. hasPurchasedSword = true
  330. elseif toolType.Name == "Bow" then
  331. hasPurchasedBow = true
  332. end
  333. local tool = game.ServerStorage.Items[toolType.Value]:Clone()
  334. tool.Parent = player.Backpack
  335. end
  336. end
  337.  
  338. if player:FindFirstChild("Package").Value == 1 then
  339. if not hasPurchasedPickaxe then
  340. local pickaxe = game.ServerStorage.Items["Obsidian Pickaxe"]:Clone()
  341. pickaxe.Parent = player.Backpack
  342. end
  343. if not hasPurchasedSword then
  344. local sword = game.ServerStorage.Items["Obsidian Sword"]:Clone()
  345. sword.Parent = player.Backpack
  346. end
  347. if not hasPurchasedBow then
  348. local bow = game.ServerStorage.Items["Obsidian bow"]:Clone()
  349. bow.Parent = player.Backpack
  350. end
  351. giveArmor(player,1)
  352. elseif player:FindFirstChild("Package").Value == 2 then
  353. if not hasPurchasedPickaxe then
  354. local pickaxe = game.ServerStorage.Items["Ruby Pickaxe"]:Clone()
  355. pickaxe.Parent = player.Backpack
  356. end
  357. if not hasPurchasedSword then
  358. local sword = game.ServerStorage.Items["Ruby Sword"]:Clone()
  359. sword.Parent = player.Backpack
  360. end
  361. if not hasPurchasedBow then
  362. local bow = game.ServerStorage.Items["Ruby bow"]:Clone()
  363. bow.Parent = player.Backpack
  364. end
  365. giveArmor(player,2)
  366. elseif player:FindFirstChild("Package").Value == 3 then
  367. if not hasPurchasedPickaxe then
  368. local pickaxe = game.ServerStorage.Items["Emerald Pickaxe"]:Clone()
  369. pickaxe.Parent = player.Backpack
  370. end
  371. if not hasPurchasedSword then
  372. local sword = game.ServerStorage.Items["Emerald Sword"]:Clone()
  373. sword.Parent = player.Backpack
  374. end
  375. if not hasPurchasedBow then
  376. local bow = game.ServerStorage.Items["Emerald bow"]:Clone()
  377. bow.Parent = player.Backpack
  378. end
  379. giveArmor(player,3)
  380. elseif player:FindFirstChild("Package").Value == 4 then
  381. if not hasPurchasedPickaxe then
  382. local pickaxe = game.ServerStorage.Items["Diamond Pickaxe"]:Clone()
  383. pickaxe.Parent = player.Backpack
  384. end
  385. if not hasPurchasedSword then
  386. local sword = game.ServerStorage.Items["Diamond Sword"]:Clone()
  387. sword.Parent = player.Backpack
  388. end
  389. if not hasPurchasedBow then
  390. local bow = game.ServerStorage.Items["Diamond bow"]:Clone()
  391. bow.Parent = player.Backpack
  392. end
  393. giveArmor(player,4)
  394. elseif player:FindFirstChild("Package").Value == 5 then
  395. if not hasPurchasedPickaxe then
  396. local pickaxe = game.ServerStorage.Items["Gold Pickaxe"]:Clone()
  397. pickaxe.Parent = player.Backpack
  398. end
  399. if not hasPurchasedSword then
  400. local sword = game.ServerStorage.Items["Gold Sword"]:Clone()
  401. sword.Parent = player.Backpack
  402. end
  403. if not hasPurchasedBow then
  404. local bow = game.ServerStorage.Items["Gold bow"]:Clone()
  405. bow.Parent = player.Backpack
  406. end
  407. giveArmor(player,5)
  408. elseif player:FindFirstChild("Package").Value == 6 then
  409. if not hasPurchasedPickaxe then
  410. local pickaxe = game.ServerStorage.Items["Iron Pickaxe"]:Clone()
  411. pickaxe.Parent = player.Backpack
  412. end
  413. if not hasPurchasedSword then
  414. local sword = game.ServerStorage.Items["Iron Sword"]:Clone()
  415. sword.Parent = player.Backpack
  416. end
  417. if not hasPurchasedBow then
  418. local bow = game.ServerStorage.Items["Iron bow"]:Clone()
  419. bow.Parent = player.Backpack
  420. end
  421. giveArmor(player,6)
  422. elseif player:FindFirstChild("Package").Value == 7 then
  423. if not hasPurchasedPickaxe then
  424. local pickaxe = game.ServerStorage.Items["Stone Pickaxe"]:Clone()
  425. pickaxe.Parent = player.Backpack
  426. end
  427. if not hasPurchasedSword then
  428. local sword = game.ServerStorage.Items["Stone Sword"]:Clone()
  429. sword.Parent = player.Backpack
  430. end
  431. if not hasPurchasedBow then
  432. local bow = game.ServerStorage.Items["Stone bow"]:Clone()
  433. bow.Parent = player.Backpack
  434. end
  435. giveArmor(player,7)
  436. else
  437. if not hasPurchasedPickaxe then
  438. local pickaxe = game.ServerStorage.Items["Wood Pickaxe"]:Clone()
  439. pickaxe.Parent = player.Backpack
  440. end
  441. if not hasPurchasedSword then
  442. local sword = game.ServerStorage.Items["Wood Sword"]:Clone()
  443. sword.Parent = player.Backpack
  444. end
  445. if not hasPurchasedBow then
  446. local bow = game.ServerStorage.Items["Wood bow"]:Clone()
  447. bow.Parent = player.Backpack
  448. end
  449. end
  450.  
  451. if player.Character then
  452. local forceField = Instance.new("ForceField")
  453. forceField.Parent = player.Character
  454. game:GetService("Debris"):AddItem(forceField, 8)
  455. end
  456.  
  457. if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 950042120) then
  458. local gravityCoil = game.ServerStorage.Items["Gravity coil"]:Clone()
  459. gravityCoil.Parent = player.Backpack
  460. end
  461.  
  462. if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 950042357) then
  463. local speedCoil = game.ServerStorage.Items["Speed coil"]:Clone()
  464. speedCoil.Parent = player.Backpack
  465. end
  466.  
  467. if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 950042602) then
  468. local epicCoil = game.ServerStorage.Items["Epic coil"]:Clone()
  469. epicCoil.Parent = player.Backpack
  470. end
  471.  
  472.  
  473. if player:FindFirstChild("Radio").Value == true then
  474. if player.Character ~= nil then
  475. if player.Character:findFirstChild("Torso") ~= nil then
  476. local radio = game.ServerStorage.Boombox:clone()
  477. radio.Parent = player.Character
  478. local weld = Instance.new("Weld")
  479. weld.Name = "BackWeld"
  480. weld.Part0 = player.Character:findFirstChild("Torso")
  481. weld.Part1 = radio
  482. weld.C0 = CFrame.new(0,0,1)
  483. weld.C0 = weld.C0 * CFrame.fromEulerAnglesXYZ(math.rad(180),math.rad(0), math.rad(180+45))
  484. weld.Parent = radio
  485. end
  486. end
  487. end
  488. end
  489. end)
  490. end
  491. wait(2)
  492. game.ReplicatedStorage.RoundInProgress.Time.Value = 3
  493. playSound("Tick3")
  494. wait(1)
  495. game.ReplicatedStorage.RoundInProgress.Time.Value = 2
  496. playSound("Tick2")
  497. wait(1)
  498. game.ReplicatedStorage.RoundInProgress.Time.Value = 1
  499. playSound("Tick1")
  500. wait(1)
  501. playSound("TickGo")
  502. game.ReplicatedStorage.RoundInProgress.Time.Value = 0
  503.  
  504. for i, player in ipairs(game.Players:GetChildren()) do
  505. if player.Character and player.Character:FindFirstChild("Torso") and player:FindFirstChild("Loaded") then
  506. player.Character.Torso.Anchored = false
  507. TPlayers = TPlayers + 1
  508. end
  509. end
  510. repeat
  511.  
  512. wait(1)
  513.  
  514. RunTime = RunTime - 1
  515.  
  516. Round.Message.Value = checkRoundPlayers().." players are left!"
  517. game.ReplicatedStorage.RoundInProgress.PlayersLeft.Value = checkRoundPlayers()
  518. game.ReplicatedStorage.RoundInProgress.Time.Value = RunTime
  519.  
  520. until checkRoundPlayers() <= 1 or RunTime < 0
  521.  
  522. Round.Value = false
  523.  
  524. game.ReplicatedStorage.RoundInProgress.Time.Value = 0
  525.  
  526. results()
  527. DestroyAllTools()
  528. game.Workspace.ActiveMap:Destroy()
  529. end
  530.  
  531.  
  532. while wait() do
  533. if checkPlayers() then
  534. start()
  535. t = 15
  536. for i=1,15 do
  537. Round.Message.Value = "Intermission..."
  538. game.ReplicatedStorage.RoundInProgress.Time.Value = t
  539. t=t-1
  540. wait(1)
  541. end
  542. game.ReplicatedStorage.RoundInProgress.Time.Value = 0
  543. game.Workspace.ActiveMusic:ClearAllChildren()
  544. else
  545. Round.Message.Value = "Waiting for 2 players to start..."
  546. game.Workspace.ActiveMusic:ClearAllChildren()
  547. end
  548. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement