Advertisement
Guest User

rustero

a guest
Oct 26th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.62 KB | None | 0 0
  1. Hint = Instance.new("Hint")
  2. Hint.Text = "Loading..."
  3. Hint.Parent = workspace
  4.  
  5. Badges = {[0] = 30058718, [100] = 29890585, [200] = 29918752, [400] = 30057939}
  6. Playing = {}
  7. Tutorial = {"http://www.roblox.com/asset/?id=30093873", "http://www.roblox.com/asset/?id=30093900", "http://www.roblox.com/asset/?id=30093954", "http://www.roblox.com/asset/?id=30094010", "http://www.roblox.com/asset/?id=30094028", "http://www.roblox.com/asset/?id=30094049"}
  8. BallName = "Orbs"
  9. Base = workspace.Base
  10. CountDownTime = 10
  11. Siz = 8
  12. Size = Vector3.new(Siz, Siz, Siz)
  13. Multiplier = 1
  14. SuckSpeed = 1.5
  15. SuckSoundId = "http://www.roblox.com/asset/?id=10722059"
  16. TickSoundId = "rbxasset://sunds\\clickfast.wav"
  17. PingSoundId = "http://www.roblox.com/asset/?id=13114759"
  18. HorrorSoundId = "http://www.roblox.com/asset/?id=2767085"
  19. LostSoundId = "http://www.roblox.com/asset/?id=13378571"
  20. WonSoundId = "http://www.roblox.com/asset/?id=15632562"
  21. EatTime = 2
  22. BallMass = 15000
  23. copyrate = 12
  24. Powerups = {}
  25. Lobby = script.Parent.Lobby
  26. VipId = 37994942
  27.  
  28. WavePoints = 200
  29. RawStages = game:GetService("Lighting"):GetChildren()
  30. Stages = {}
  31. for i, v in pairs(RawStages) do
  32. if v:IsA("Model") then
  33. local c = math.random(0, 1)
  34. if c == 0 then
  35. table.insert(Stages, 1, v)
  36. else
  37. table.insert(Stages, v)
  38. end
  39. end
  40. end
  41. Index = math.random(1, #Stages)
  42. TickSound = Instance.new("Sound")
  43. TickSound.Pitch = 2
  44. TickSound.Volume = 0.3
  45. TickSound.SoundId = TickSoundId
  46. TickSound.Parent = workspace
  47. PingSound = Instance.new("Sound")
  48. PingSound.Pitch = 0.7
  49. PingSound.Volume = 1
  50. PingSound.SoundId = PingSoundId
  51. PingSound.Parent = workspace
  52. HorrorSound = Instance.new("Sound")
  53. HorrorSound.Pitch = 1.5
  54. HorrorSound.Volume = 0.3
  55. HorrorSound.SoundId = HorrorSoundId
  56. HorrorSound.Parent = workspace
  57. LostSound = Instance.new("Sound")
  58. LostSound.Pitch = 0.5
  59. LostSound.Volume = 1
  60. LostSound.SoundId = LostSoundId
  61. LostSound.Parent = workspace
  62. WonSound = Instance.new("Sound")
  63. WonSound.Pitch = 1.2
  64. WonSound.Volume = 1
  65. WonSound.SoundId = WonSoundId
  66. WonSound.Parent = workspace
  67.  
  68. function AwardBadge(Player, Badge)
  69. spawn(function() game:GetService("BadgeService"):AwardBadge(Player.userId, Badge) end)
  70. end
  71. function Talk(Text, Time)
  72. Hint.Text = Text
  73. --collectgarbage("collect")
  74. wait(Time)
  75. end
  76. function GetStage()
  77. Talk("Choosing stage...", 2)
  78. local index = Index
  79. local frames = 15
  80. for i = 1, frames do
  81. index = index + 1
  82. if index > #Stages then index = 1 end
  83. TickSound:Play()
  84. Talk("Stage: " .. Stages[index].Name, i/frames*0.5)
  85. end
  86. Index = Index + 1
  87. if Index > #Stages then Index = 1 end
  88. local Stage = Stages[Index]
  89. Talk("Stage: " .. Stage.Name, 0.6)
  90. PingSound:Play()
  91. Talk(Stage.Name .. " is selected!", 5)
  92. return Stage
  93. end
  94. function StartWave()
  95. WaveTime = 60
  96. local pSurvivors = game:GetService("Players"):GetChildren()
  97. local nPlayers = 0
  98. for Index, Survivor in pairs(pSurvivors) do
  99. if Playing[Survivor] then
  100. nPlayers = nPlayers + 1
  101. end
  102. end
  103. if nPlayers == 0 then Talk("No players? Skipping round...", 4) return true end
  104. Survivors = {}
  105. for Index, Survivor in pairs(pSurvivors) do
  106. if Playing[Survivor] then
  107. pcall(function()
  108. Survivor.Character:MoveTo(Vector3.new(math.random(-189.5, 10.5), 35, math.random(-90, 90)))
  109. while (Vector3.new() - Survivor.Character.Humanoid.Torso.Position).magnitude < -15 do
  110. Survivor.Character:MoveTo(Vector3.new(math.random(-189.5, 10.5), 35, math.random(-90, 90)))
  111. end
  112. Survivor.Character.Humanoid.Died:connect(function() Survivors[Survivor] = nil end)
  113. Survivors[Survivor] = true
  114. WaveTime = WaveTime + 3.75
  115. end)
  116. end
  117. end
  118. WaveTime = math.floor(WaveTime)
  119. Hungries = Instance.new("Model")
  120. Hungries.Name = "Hungries"
  121. Hungries.Parent = workspace
  122. Talk("Starting game...", 2)
  123. HorrorSound:Play()
  124. spawn(function()
  125. Infections = {}
  126. function GetClosestPart(c)
  127. local t, dist = nil, 100000
  128. for _ in pairs(Survivors) do
  129. local e
  130. if pcall(function() e = Survivors.Character.Humanoid.Torso end) then
  131. if (c.Position - e.Position).magnitude < dist then
  132. dist = (c.Position - e.Position).magnitude
  133. t = e
  134. end
  135. end
  136. end
  137. return t, dist
  138. end
  139. function Eat(part, ir, s)
  140. part.CanCollide = false
  141. part.Anchored = true
  142. while (part.Position - ir.Position).magnitude > Siz / 3 do
  143. local c = {part.CFrame:components()}
  144. local v = part.Position + CFrame.new(part.Position, ir.Position).lookVector * SuckSpeed
  145. c[1] = v.X
  146. c[2] = v.Y
  147. c[3] = v.Z
  148. part.CFrame = CFrame.new(unpack(c))
  149. wait()
  150. end
  151. s:Play()
  152. part.Anchored = false
  153. part:BreakJoints()
  154. local p = Join(ir, part)
  155. wait(EatTime)
  156. if p.Parent then
  157. Kill(part)
  158. end
  159. end
  160. function Kill(part)
  161. part:Remove() -- For now.
  162. end
  163. function Join(Part0, Part1)
  164. local Connector = Instance.new("Weld")
  165. Connector.C0 = Part0.CFrame:inverse()
  166. Connector.C1 = Part1.CFrame:inverse()
  167. Connector.Part0 = Part0
  168. Connector.Part1 = Part1
  169. Connector.Parent = Part0
  170. return Connector
  171. end
  172. function MakeNew(pos)
  173. local ttt = 0
  174. local i = Instance.new("Part")
  175. Infections[i] = true
  176. i.BottomSurface = 0
  177. i.Color = Color3.new(math.random(0, 1), math.random(0, 1), math.random(0, 1))
  178. i.formFactor = 0
  179. i.Locked = true
  180. i.Parent = Hungries
  181. i.Position = pos
  182. i.Shape = 0
  183. i.Size = Size
  184. i.Transparency = 0.3
  185. i.TopSurface = 0
  186. local s = Instance.new("Sound")
  187. s.SoundId = SuckSoundId
  188. s.Parent = i
  189. i.Touched:connect(function(Hit)
  190. if Hit:GetMass() < BallMass and not Infections[Hit] and not Hit:IsDescendantOf(Lobby) then
  191. Infections[Hit] = true
  192. Eat(Hit, i, s)
  193. ttt = ttt + 1
  194. if ttt > copyrate then
  195. ttt = 0
  196. for i = 1, Multiplier do
  197. MakeNew(Hit.Position)
  198. end
  199. end
  200. end
  201. end)
  202. local life = 40
  203. local v = Instance.new("BodyAngularVelocity")
  204. v.angularvelocity = Vector3.new()
  205. v.P = 3
  206. v.maxTorque = Vector3.new(1e+15, 1e+15, 1e+15)
  207. v.Parent = i
  208. while true do
  209. wait(0.1)
  210. if i.Position.X < -95 or i.Position.X > 95 or i.Position.Y < 0 or i.Position.Y > 40 or i.Position.Z < -95 or i.Position.Z > 95 then
  211. i.Position = Vector3.new()
  212. end
  213. if math.random(1, 50) == 1 then
  214. i.Velocity = i.Velocity + Vector3.new(0, 50, 0)
  215. end
  216. if i.Velocity.magnitude > 50 then
  217. i.Velocity = i.Velocity.unit * 50
  218. end
  219. local t, Dist = GetClosestPart(i)
  220. if t then
  221. t = t.Position - i.Position
  222. local x = -t.z
  223. local y = -12.94
  224. local z = t.x
  225. v.angularvelocity = -Vector3.new(x, y, z).unit * 40 * ((t.x^2+t.z^2)^0.5/Dist/4+0.75)
  226. end
  227. life = life - 0.1
  228. if life <= 0 then
  229. break
  230. end
  231. end
  232. Kill(i, i)
  233. end
  234. MakeNew(Vector3.new())
  235. end)
  236. for i = WaveTime, 0, -1 do
  237. Talk(i .. " seconds till wave ends. Survive for points!", 1)
  238. local nSurvivors = 0
  239. for Survivor in pairs(Survivors) do
  240. nSurvivors = nSurvivors + 1
  241. end
  242. if nSurvivors == 0 then
  243. LostSound:Play()
  244. Talk("All players FAILED!", 3)
  245. break
  246. end
  247. if #Hungries:GetChildren() == 0 then
  248. WonSound:Play()
  249. Talk("All " .. BallName .. " died!", 3)
  250. break
  251. end
  252. end
  253. end
  254. function EndWave()
  255. Infections = {}
  256. Hungries:Remove()
  257. PingSound:Play()
  258. Talk("Game over!", 4)
  259. local nSurvivors = 0
  260. for Survivor in pairs(Survivors) do
  261. nSurvivors = nSurvivors + 1
  262. end
  263. local Index = 1
  264. local sSurvivors = ""
  265. for Survivor in pairs(Survivors) do
  266. if Index > 1 then
  267. if Index == nSurvivors then
  268. sSurvivors = sSurvivors .. " and "
  269. else
  270. sSurvivors = sSurvivors .. ", "
  271. end
  272. end
  273. sSurvivors = sSurvivors .. Survivor.Name
  274. Index = Index + 1
  275. end
  276. if nSurvivors > 0 then
  277. local Points = math.ceil(WavePoints / nSurvivors)
  278. for Survivor in pairs(Survivors) do
  279. pcall(function() Survivor.leaderstats.Points.Value = Survivor.leaderstats.Points.Value + Points end)
  280. pcall(function() Survivor.Character:BreakJoints() end)
  281. pcall(function() for Index, Value in pairs(Badges) do if Survivor.leaderstats.Points.Value >= Index then AwardBadge(Survivor, Value) end end end)
  282. end
  283. Talk(sSurvivors .. " survived and got " .. Points .. " points.", 4)
  284. else
  285. Talk("Everybody died. No points for this round.", 4)
  286. end
  287. end
  288. function CountDown()
  289. for i = CountDownTime, 0, -1 do
  290. Talk("New game starting in " .. i .. " seconds.", 1)
  291. end
  292. end
  293. function GetMass(Object, Mass)
  294. Mass = Mass or 0
  295. if Object:IsA("BasePart") then Mass = Mass + Object:GetMass() end
  296. for Index, Value in pairs(Object:GetChildren()) do
  297. Mass = GetMass(Value, Mass)
  298. end
  299. return Mass
  300. end
  301. function UpdatePowerUps(Player)
  302. pcall(function() Player.Character.Humanoid.WalkSpeed = Powerups[Player].WalkSpeed end)
  303. pcall(function()
  304. local Torso = Player.Character.Humanoid.Torso
  305. local AntiGrav = Torso:FindFirstChild("BodyForce") or Instance.new("BodyForce")
  306. AntiGrav.force = Vector3.new(0, GetMass(Player.Character) * 196.2 * Powerups[Player].AntiGrav / 100, 0)
  307. AntiGrav.Parent = Torso
  308. end)
  309. end
  310. function PlayerJoined(Player)
  311. local Stats = Instance.new("IntValue")
  312. Stats.Name = "leaderstats"
  313. Stats.Parent = Player
  314. local Points = Instance.new("IntValue")
  315. Points.Name = "Points"
  316. Points.Value = 0
  317. Points.Parent = Stats
  318. Powerups[Player] = {WalkSpeed = 16, AntiGrav = 0}
  319. Player.CharacterAdded:connect(function(Character)
  320. UpdatePowerUps(Player)
  321. Character.DescendantAdded:connect(function()
  322. UpdatePowerUps(Player)
  323. end)
  324. Character.DescendantRemoving:connect(function()
  325. UpdatePowerUps(Player)
  326. end)
  327. local Gui = Instance.new("ScreenGui")
  328. Gui.Name = "SpectateGui"
  329. local Button = Instance.new("TextButton")
  330. Button.BackgroundColor3 = Color3.new(0.1, 0.8, 0.9)
  331. Button.BackgroundTransparency = 0.2
  332. Button.Position = UDim2.new(0, 0, 1, -90)
  333. Button.Size = UDim2.new(0, 350, 0, 20)
  334. Button.Text = ({[false] = "Spectating", [true] = "Playing"})[Playing[Player]] .. " (Click to switch)"
  335. Button.Parent = Gui
  336. Button.MouseButton1Click:connect(function()
  337. Playing[Player] = not Playing[Player]
  338. Button.Text = ({[false] = "Spectating", [true] = "Playing"})[Playing[Player]] .. " (Click to switch). It will affect you whenever a new round starts."
  339. end)
  340. local WalkspeedUp = Instance.new("TextButton")
  341. WalkspeedUp.BackgroundColor3 = Color3.new(0.9, 0.9, 0.9)
  342. WalkspeedUp.BackgroundTransparency = 0.2
  343. WalkspeedUp.Position = UDim2.new(0, 0, 1, -110)
  344. WalkspeedUp.Size = UDim2.new(0, 155, 0, 20)
  345. WalkspeedUp.Text = "WalkSpeed +2 for 50 points (" .. Powerups[Player]["WalkSpeed"] .. ")"
  346. WalkspeedUp.Parent = Gui
  347. WalkspeedUp.MouseButton1Click:connect(function()
  348. if Powerups[Player]["WalkSpeed"] < 60 then
  349. if Points.Value >= 50 then
  350. Points.Value = Points.Value - 50
  351. Powerups[Player]["WalkSpeed"] = Powerups[Player]["WalkSpeed"] + 2
  352. WalkspeedUp.Text = "WalkSpeed +2 for 50 points (" .. Powerups[Player]["WalkSpeed"] .. ")"
  353. UpdatePowerUps(Player)
  354. end
  355. end
  356. if Powerups[Player]["WalkSpeed"] >= 60 then
  357. WalkspeedUp.Text = "WalkSpeed Maximum (60)"
  358. end
  359. end)
  360. local GravityUp = Instance.new("TextButton")
  361. GravityUp.BackgroundColor3 = Color3.new(0.9, 0.9, 0.9)
  362. GravityUp.BackgroundTransparency = 0.2
  363. GravityUp.Position = UDim2.new(0, 0, 1, -130)
  364. GravityUp.Size = UDim2.new(0, 155, 0, 20)
  365. GravityUp.Text = "Gravity -4% for 50 points (" .. 100 - Powerups[Player]["AntiGrav"] .. "%)"
  366. GravityUp.Parent = Gui
  367. GravityUp.MouseButton1Click:connect(function()
  368. if Powerups[Player]["AntiGrav"] < 60 then
  369. if Points.Value >= 50 then
  370. Points.Value = Points.Value - 50
  371. Powerups[Player]["AntiGrav"] = Powerups[Player]["AntiGrav"] + 4
  372. GravityUp.Text = "Gravity -4% for 50 points (" .. 100 - Powerups[Player]["AntiGrav"] .. "%)"
  373. UpdatePowerUps(Player)
  374. end
  375. if Powerups[Player]["AntiGrav"] >= 60 then
  376. GravityUp.Text = "Gravity Minimum (40%)"
  377. end
  378. end
  379. end)
  380. local TutorialLabel = Instance.new("ImageLabel")
  381. TutorialLabel.BackgroundColor3 = Color3.new(1, 0.9, 0.2)
  382. TutorialLabel.BackgroundTransparency = 0.2
  383. TutorialLabel.Position = UDim2.new(0, 0, 1, -268)
  384. TutorialLabel.Size = UDim2.new(0, 1, 0, 1)
  385. TutorialLabel.Parent = Gui
  386. local Index = 0
  387. local PlayerGui = Player:FindFirstChild("PlayerGui")
  388. while not PlayerGui do wait() PlayerGui = Player:FindFirstChild("PlayerGui") end
  389. Gui.Parent = PlayerGui
  390. while PlayerGui.Parent do
  391. Index = Index + 1
  392. if Index > #Tutorial then Index = 1 end
  393. TutorialLabel.Image = Tutorial[Index]
  394. wait(5)
  395. end
  396. end)
  397. Playing[Player] = true
  398. spawn(function()
  399. if game:GetService("BadgeService"):UserHasBadge(Player.userId, VipId) then
  400. Powerups[Player] = {WalkSpeed = 30, AntiGrav = 24}
  401. end
  402. end)
  403. end
  404. function PlayerLeft(Player)
  405. pcall(function() Survivors[Player] = nil end)
  406. end
  407. game:GetService("Players").PlayerAdded:connect(PlayerJoined)
  408. game:GetService("Players").PlayerRemoving:connect(PlayerLeft)
  409.  
  410. while true do
  411. if game:GetService("Players").NumPlayers > 0 then
  412. CountDown()
  413. local Stage = GetStage():Clone()
  414. if Stage:FindFirstChild("BaseColor") then
  415. Base.BrickColor = Stage.BaseColor.Value
  416. else
  417. Base.BrickColor = BrickColor.new("Camo")
  418. end
  419. Stage.Parent = workspace
  420. Stage:MakeJoints()
  421. Base:MakeJoints()
  422. for Index, Object in pairs(Stage:GetChildren()) do if Object:IsA("BasePart") then Object.Velocity = Vector3.new() Object.RotVelocity = Vector3.new() end end
  423. local b = StartWave()
  424. Stage:Remove()
  425. if not b then
  426. EndWave()
  427. end
  428. Base.BrickColor = BrickColor.new("Navy blue")
  429. else
  430. wait()
  431. end
  432. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement