lolita5432

LOTMLOP

Jan 6th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.97 KB | None | 0 0
  1.  
  2. --:3
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Tool0 = Instance.new("Tool")
  20. Part1 = Instance.new("Part")
  21. Sound2 = Instance.new("Sound")
  22. SpecialMesh3 = Instance.new("SpecialMesh")
  23. LocalScript4 = Instance.new("LocalScript")
  24. Script5 = Instance.new("Script")
  25. Sound6 = Instance.new("Sound")
  26. Sound7 = Instance.new("Sound")
  27. Script8 = Instance.new("Script")
  28. LocalScript9 = Instance.new("LocalScript")
  29. Animation10 = Instance.new("Animation")
  30. LocalScript11 = Instance.new("LocalScript")
  31. LocalScript12 = Instance.new("LocalScript")
  32. ObjectValue13 = Instance.new("ObjectValue")
  33. Tool0.Name = "Super OP LoTMLauncher"
  34. Tool0.Parent = mas
  35. Tool0.TextureId = "http://www.roblox.com/asset/?id=135409747"
  36. Tool0.GripPos = Vector3.new(0.0500000007, -0.600000024, -1)
  37. Tool0.ToolTip = "EXTREMELY OP USE OF CAUTION"
  38. Part1.Name = "Handle"
  39. Part1.Parent = Tool0
  40. Part1.FormFactor = Enum.FormFactor.Custom
  41. Part1.Size = Vector3.new(0.839999974, 1.14999998, 3.55000019)
  42. Part1.CFrame = CFrame.new(1, 0.574999988, 12.4000015, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  43. Part1.BottomSurface = Enum.SurfaceType.Smooth
  44. Part1.TopSurface = Enum.SurfaceType.Smooth
  45. Part1.Position = Vector3.new(1, 0.574999988, 12.4000015)
  46. Sound2.Name = "ReloadSound"
  47. Sound2.Parent = Part1
  48. Sound2.SoundId = "http://www.roblox.com/Asset?ID=10209813"
  49. Sound2.Volume = 1
  50. SpecialMesh3.Parent = Part1
  51. SpecialMesh3.MeshId = "http://www.roblox.com/asset/?id=125754898"
  52. SpecialMesh3.TextureId = "http://www.roblox.com/asset/?id=125755118"
  53. SpecialMesh3.VertexColor = Vector3.new(1, 0, 0)
  54. SpecialMesh3.MeshType = Enum.MeshType.FileMesh
  55. LocalScript4.Name = "MouseIcon"
  56. LocalScript4.Parent = Tool0
  57. table.insert(cors,sandbox(LocalScript4,function()
  58. local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
  59. local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
  60.  
  61. local Tool = script.Parent
  62.  
  63. local Mouse = nil
  64.  
  65. local function UpdateIcon()
  66. Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
  67. end
  68.  
  69. local function OnEquipped(mouse)
  70. Mouse = mouse
  71. UpdateIcon()
  72. end
  73.  
  74. local function OnChanged(property)
  75. if property == 'Enabled' then
  76. UpdateIcon()
  77. end
  78. end
  79.  
  80. Tool.Equipped:connect(OnEquipped)
  81. Tool.Changed:connect(OnChanged)
  82.  
  83. end))
  84. Script5.Name = "Launcher"
  85. Script5.Parent = Tool0
  86. table.insert(cors,sandbox(Script5,function()
  87. -----------------
  88. --| Constants |--
  89. -----------------
  90.  
  91. local COOLDOWN = 0 -- Seconds until tool can be used again
  92.  
  93. -- RocketPropulsion Fields
  94. local TARGET_RADIUS = 70
  95. local MAX_SPEED = 2500
  96. local MAX_TORQUE = Vector3.new(4e6, 4e6, 0)
  97. local MAX_THRUST = 640000
  98. local THRUST_P = 6700
  99. local THRUST_D = 67000
  100.  
  101. local TARGET_OVERSHOOT_DISTANCE = 10000000
  102.  
  103. local ROCKET_MESH_ID = 'http://www.roblox.com/asset/?id=16974203'
  104. local ROCKET_MESH_SCALE = Vector3.new(2.5, 2.5, 2)
  105. local ROCKET_PART_SIZE = Vector3.new(1, 1, 4)
  106.  
  107. --------------------
  108. --| WaitForChild |--
  109. --------------------
  110.  
  111. -- Waits for parent.child to exist, then returns it
  112. local function WaitForChild(parent, childName)
  113. assert(parent, "ERROR: WaitForChild: parent is nil")
  114. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  115. return parent[childName]
  116. end
  117.  
  118. -----------------
  119. --| Variables |--
  120. -----------------
  121.  
  122. local DebrisService = Game:GetService('Debris')
  123. local PlayersService = Game:GetService('Players')
  124.  
  125. local Tool = script.Parent
  126. local ToolHandle = Tool.Handle
  127.  
  128. local RocketScript = WaitForChild(script, 'Rocket')
  129.  
  130. local SwooshSound = WaitForChild(script, 'Swoosh')
  131. local BoomSound = WaitForChild(script, 'Boom')
  132. local ReloadSound = WaitForChild(ToolHandle, 'ReloadSound')
  133.  
  134. local MyModel = nil
  135. local MyPlayer = nil
  136.  
  137. local BaseRocket = nil
  138. local RocketClone = nil
  139.  
  140. -----------------
  141. --| Functions |--
  142. -----------------
  143.  
  144. local function MakeBaseRocket()
  145. -- Set up the rocket part
  146. local rocket = Instance.new('Part')
  147. rocket.Name = 'Rocket'
  148. rocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
  149. rocket.Size = ROCKET_PART_SIZE
  150. rocket.CanCollide = false
  151. rocket.BottomSurface = Enum.SurfaceType.Smooth
  152. rocket.TopSurface = Enum.SurfaceType.Smooth
  153.  
  154. -- Add the mesh
  155. local mesh = Instance.new('SpecialMesh', rocket)
  156. mesh.MeshId = ROCKET_MESH_ID
  157. mesh.Scale = ROCKET_MESH_SCALE
  158. mesh.TextureId = ToolHandle.Mesh.TextureId
  159.  
  160. -- Add fire
  161. local fire = Instance.new('Fire', rocket)
  162. fire.Heat = 10
  163. fire.Size = 10
  164.  
  165. -- Add the propulsion
  166. local rocketPropulsion = Instance.new('RocketPropulsion', rocket)
  167. rocketPropulsion.CartoonFactor = 1
  168. rocketPropulsion.TargetRadius = TARGET_RADIUS
  169. rocketPropulsion.MaxSpeed = MAX_SPEED
  170. rocketPropulsion.MaxTorque = MAX_TORQUE
  171. rocketPropulsion.MaxThrust = MAX_THRUST
  172. rocketPropulsion.ThrustP = THRUST_P
  173. rocketPropulsion.ThrustD = THRUST_D
  174.  
  175. -- Clone the sounds
  176. local swooshSoundClone = SwooshSound:Clone()
  177. swooshSoundClone.Parent = rocket
  178. local boomSoundClone = BoomSound:Clone()
  179. boomSoundClone.Parent = rocket
  180.  
  181. -- Attach creator tags
  182. local creatorTag = Instance.new('ObjectValue', rocket)
  183. creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
  184. creatorTag.Value = MyPlayer
  185. local iconTag = Instance.new('StringValue', creatorTag)
  186. iconTag.Name = 'icon'
  187. iconTag.Value = Tool.TextureId
  188.  
  189. -- Finally, clone the rocket script and enable it
  190. local rocketScriptClone = RocketScript:Clone()
  191. rocketScriptClone.Parent = rocket
  192. rocketScriptClone.Disabled = false
  193.  
  194. return rocket
  195. end
  196.  
  197. local function OnEquipped()
  198. MyModel = Tool.Parent
  199. MyPlayer = PlayersService:GetPlayerFromCharacter(MyModel)
  200. BaseRocket = MakeBaseRocket()
  201. RocketClone = BaseRocket:Clone()
  202. end
  203.  
  204. local function OnActivated(byFireButton)
  205. if Tool.Enabled and MyModel and MyModel:FindFirstChild('Humanoid') and MyModel.Humanoid.Health > 0 then
  206. Tool.Enabled = false
  207.  
  208. -- Get the target position
  209. local targetPosition = MyModel.Humanoid.TargetPoint
  210. if byFireButton then -- Using Fire Button, shoot forwards
  211. targetPosition = MyModel.Humanoid.Torso.CFrame.lookVector * 1000
  212. end
  213.  
  214. -- Position the rocket clone
  215. local spawnPosition = ToolHandle.Position + (ToolHandle.CFrame.lookVector * (ToolHandle.Size.z / 2))
  216. RocketClone.CFrame = CFrame.new(spawnPosition, targetPosition) --NOTE: This must be done before assigning Parent
  217. DebrisService:AddItem(RocketClone, 30)
  218. RocketClone.Parent = Workspace
  219.  
  220. -- Assign target and launch!
  221. local rocketPropulsion = RocketClone:FindFirstChild('RocketPropulsion')
  222. if rocketPropulsion then
  223. local direction = (targetPosition - RocketClone.Position).unit
  224. rocketPropulsion.TargetOffset = RocketClone.Position + (direction * TARGET_OVERSHOOT_DISTANCE)
  225. rocketPropulsion:Fire()
  226. end
  227.  
  228. wait(0) --TODO: Remove when sounds realize they can be played as soon as they enter the Workspace
  229.  
  230. -- Swoosh!
  231. local swooshSound = RocketClone:FindFirstChild('Swoosh')
  232. if swooshSound then
  233. swooshSound:Play()
  234. end
  235.  
  236. -- Prepare the next rocket to be fired
  237. RocketClone = BaseRocket:Clone()
  238.  
  239. ReloadSound:Play()
  240.  
  241. wait(COOLDOWN)
  242.  
  243. -- Stop the reloading sound if it hasn't already finished
  244. ReloadSound:Stop()
  245.  
  246. Tool.Enabled = true
  247. end
  248. end
  249.  
  250. local function OnUnequipped()
  251. ReloadSound:Stop() --TODO: This does not work online
  252. end
  253.  
  254. -- Also activate when the Fire Button is down
  255. local function OnChildAdded(child)
  256. if child.Name == 'FireButtonDown' then
  257. child.Changed:connect(function(newValue)
  258. if newValue == true then
  259. OnActivated(true)
  260. end
  261. end)
  262. end
  263. end
  264.  
  265. --------------------
  266. --| Script Logic |--
  267. --------------------
  268.  
  269. Tool.Equipped:connect(OnEquipped)
  270. Tool.Activated:connect(OnActivated)
  271. Tool.Unequipped:connect(OnUnequipped)
  272. Tool.ChildAdded:connect(OnChildAdded) --NOTE: Added for Fire Button
  273.  
  274. end))
  275. Sound6.Name = "Boom"
  276. Sound6.Parent = Script5
  277. Sound6.SoundId = "http://www.roblox.com/asset/?id=78491401"
  278. Sound6.Volume = 1
  279. Sound7.Name = "Swoosh"
  280. Sound7.Parent = Script5
  281. Sound7.SoundId = "http://www.roblox.com/asset/?id=10209821"
  282. Sound7.Volume = 0.69999998807907
  283. Sound7.Looped = true
  284. Script8.Name = "Rocket"
  285. Script8.Parent = Script5
  286. Script8.Disabled = true
  287. table.insert(cors,sandbox(Script8,function()
  288. -----------------
  289. --| Constants |--
  290. -----------------
  291.  
  292. local BLAST_RADIUS = 130
  293. local BLAST_PRESSURE = 1000000
  294.  
  295. -- Rocket will fly through things named these
  296. local ROCKET_IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} --NOTE: Keys must be lowercase, values must evaluate to true
  297.  
  298. --------------------
  299. --| WaitForChild |--
  300. --------------------
  301.  
  302. -- Waits for parent.child to exist, then returns it
  303. local function WaitForChild(parent, childName)
  304. assert(parent, "ERROR: WaitForChild: parent is nil")
  305. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  306. return parent[childName]
  307. end
  308.  
  309. -----------------
  310. --| Variables |--
  311. -----------------
  312.  
  313. local DebrisService = Game:GetService('Debris')
  314.  
  315. local Rocket = script.Parent
  316. local CreatorTag = WaitForChild(Rocket, 'creator')
  317.  
  318. local Connection = nil
  319.  
  320. -----------------
  321. --| Functions |--
  322. -----------------
  323.  
  324. -- Returns the ancestor that contains a Humanoid, if it exists
  325. local function FindCharacterAncestor(subject)
  326. if subject and subject ~= Workspace then
  327. local humanoid = subject:FindFirstChild('Humanoid')
  328. if humanoid then
  329. return subject, humanoid
  330. else
  331. return FindCharacterAncestor(subject.Parent)
  332. end
  333. end
  334. return nil
  335. end
  336.  
  337. local function OnExplosionHit(hitPart)
  338. if hitPart then
  339. local _, humanoid = FindCharacterAncestor(hitPart.Parent)
  340. if humanoid and humanoid.Health > 0 then
  341. local hitBindable = humanoid:FindFirstChild('Hit')
  342. if hitBindable then
  343. hitBindable:Invoke(0, CreatorTag)
  344. else
  345. print("Could not find BindableFunction 'Hit'")
  346. end
  347. end
  348. end
  349. end
  350.  
  351. local function OnTouched(otherPart)
  352. if Rocket and otherPart then
  353. -- Fly through anything in the ignore list
  354. if ROCKET_IGNORE_LIST[string.lower(otherPart.Name)] then
  355. return
  356. end
  357.  
  358. -- Fly through the creator
  359. local myPlayer = CreatorTag.Value
  360. if myPlayer and myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then
  361. return
  362. end
  363.  
  364. -- Create the explosion
  365. local explosion = Instance.new('Explosion')
  366. explosion.BlastPressure = BLAST_PRESSURE
  367. explosion.BlastRadius = BLAST_RADIUS
  368. explosion.Position = Rocket.Position
  369. explosion.Hit:connect(OnExplosionHit)
  370. explosion.Parent = Workspace
  371.  
  372. -- Start playing the boom sound
  373. local boomSound = Rocket:FindFirstChild('Boom')
  374. if boomSound then
  375. boomSound:Play()
  376. end
  377.  
  378. -- NOTE:
  379. -- If we just destroyed the rocket at this point, the boom sound would be destroyed too,
  380. -- so instead we will hide the rocket, keep it in the same spot, and schedule it for deletion
  381.  
  382. -- Stop playing the swoosh sound
  383. local swooshSound = Rocket:FindFirstChild('Swoosh')
  384. if swooshSound then
  385. swooshSound:Stop()
  386. end
  387.  
  388. -- Put out the fire
  389. local fire = Rocket:FindFirstChild('Fire')
  390. if fire then
  391. fire:Destroy()
  392. end
  393.  
  394. Rocket.Transparency = 1
  395. Rocket.CanCollide = false
  396. Rocket.Anchored = true
  397. DebrisService:AddItem(Rocket, 3)
  398.  
  399. -- Destroy the connection so this method won't be called again
  400. Connection:disconnect()
  401. end
  402. end
  403.  
  404. --------------------
  405. --| Script Logic |--
  406. --------------------
  407.  
  408. -- Arm the rocket and save the touch connection so we can disconnect it later
  409. Connection = Rocket.Touched:connect(OnTouched)
  410.  
  411. end))
  412. LocalScript9.Name = "Animation"
  413. LocalScript9.Parent = Tool0
  414. table.insert(cors,sandbox(LocalScript9,function()
  415. --------------------
  416. --| WaitForChild |--
  417. --------------------
  418.  
  419. -- Waits for parent.child to exist, then returns it
  420. local function WaitForChild(parent, childName)
  421. assert(parent, "ERROR: WaitForChild: parent is nil")
  422. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  423. return parent[childName]
  424. end
  425.  
  426. -----------------
  427. --| Variables |--
  428. -----------------
  429.  
  430. local Tool = script.Parent
  431.  
  432. local FireAndReloadAnimation = WaitForChild(script, 'FireAndReload')
  433.  
  434. local FireAndReloadTrack = nil
  435.  
  436. -----------------
  437. --| Functions |--
  438. -----------------
  439.  
  440. local function OnEquipped()
  441. local myModel = Tool.Parent
  442. local humanoid = myModel:FindFirstChild('Humanoid')
  443. if humanoid then -- Preload animations
  444. FireAndReloadTrack = humanoid:LoadAnimation(FireAndReloadAnimation)
  445. end
  446. end
  447.  
  448. local function OnChanged(property)
  449. if property == 'Enabled' and Tool.Enabled == false then
  450. -- Play fire and reload animation
  451. if FireAndReloadTrack then
  452. FireAndReloadTrack:Play()
  453. end
  454. end
  455. end
  456.  
  457. local function OnUnequipped()
  458. -- Stop animations
  459. if FireAndReloadTrack then FireAndReloadTrack:Stop() end
  460. end
  461.  
  462. --------------------
  463. --| Script Logic |--
  464. --------------------
  465.  
  466. Tool.Equipped:connect(OnEquipped)
  467. Tool.Changed:connect(OnChanged)
  468. Tool.Unequipped:connect(OnUnequipped)
  469.  
  470. end))
  471. Animation10.Name = "FireAndReload"
  472. Animation10.Parent = LocalScript9
  473. Animation10.AnimationId = "http://www.roblox.com/Asset?ID=94771598"
  474. LocalScript11.Name = "VisualizeReload"
  475. LocalScript11.Parent = Tool0
  476. table.insert(cors,sandbox(LocalScript11,function()
  477. -----------------
  478. --| Constants |--
  479. -----------------
  480.  
  481. local ROCKET_MESH_ID = 'http://www.roblox.com/asset/?id=16974203'
  482. local ROCKET_MESH_SCALE = Vector3.new(1, 1, 1)
  483.  
  484. local ANIM_TOTAL_TIME = 3.4 -- Total length of FireAndReload animation
  485. local ROCKET_SHOW_TIME = 1.5 -- Seconds after animation begins to show the rocket
  486. local ROCKET_HIDE_TIME = 2.2 -- Seconds after animation begins to hide the rocket
  487.  
  488. -----------------
  489. --| Variables |--
  490. -----------------
  491.  
  492. local Tool = script.Parent
  493. local ToolHandle = Tool.Handle
  494.  
  495. local MyModel = nil
  496. local ReloadRocket = nil
  497.  
  498. local StillEquipped = false
  499.  
  500. -----------------
  501. --| Functions |--
  502. -----------------
  503.  
  504. local function MakeReloadRocket()
  505. local reloadRocket = Instance.new('Part')
  506. reloadRocket.Name = "Ammo"
  507. reloadRocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
  508. reloadRocket.Size = Vector3.new() -- As small as possible
  509.  
  510. local mesh = Instance.new('SpecialMesh', reloadRocket)
  511. mesh.MeshId = ROCKET_MESH_ID
  512. mesh.Scale = ROCKET_MESH_SCALE
  513. mesh.TextureId = ToolHandle.Mesh.TextureId
  514.  
  515. return reloadRocket
  516. end
  517.  
  518. local function OnEquipped()
  519. MyModel = Tool.Parent
  520. ReloadRocket = MakeReloadRocket()
  521. end
  522.  
  523. local function OnChanged(property)
  524. if property == 'Enabled' and Tool.Enabled == false then
  525. -- Show the next rocket going into the launcher
  526. StillEquipped = true
  527. wait(ROCKET_SHOW_TIME)
  528. if StillEquipped then
  529. local leftArm = MyModel:FindFirstChild('Left Arm')
  530. if leftArm then
  531. local weld = ReloadRocket:FindFirstChild('Weld')
  532. if not weld then
  533. weld = Instance.new('Weld')
  534. weld.Part0 = leftArm
  535. weld.Part1 = ReloadRocket
  536. weld.C1 = CFrame.new(Vector3.new(0, 1, 0))
  537. weld.Parent = ReloadRocket
  538. end
  539. ReloadRocket.Parent = MyModel
  540. end
  541. wait(ROCKET_HIDE_TIME - ROCKET_SHOW_TIME)
  542. if StillEquipped and ReloadRocket.Parent == MyModel then
  543. ReloadRocket.Parent = nil
  544. end
  545. end
  546. end
  547. end
  548.  
  549. local function OnUnequipped()
  550. StillEquipped = false
  551. ReloadRocket:Destroy()
  552. ReloadRocket = nil
  553. end
  554.  
  555. --------------------
  556. --| Script Logic |--
  557. --------------------
  558.  
  559. Tool.Equipped:connect(OnEquipped)
  560. Tool.Changed:connect(OnChanged)
  561. Tool.Unequipped:connect(OnUnequipped)
  562.  
  563. end))
  564. LocalScript12.Name = "EpicEffect"
  565. LocalScript12.Parent = Tool0
  566. table.insert(cors,sandbox(LocalScript12,function()
  567. Tool = script.Parent
  568. gyro = Instance.new("BodyGyro")
  569. script.Gyro.Value = gyro
  570.  
  571. onMouseMove=function(mouse)
  572. vCharacter = Tool.Parent
  573. if vCharacter ~= nil then
  574. local tp = vCharacter.Humanoid.TargetPoint
  575. tp = Vector3.new(tp.X,Tool.Parent.Torso.Position.Y,tp.Z)
  576. local dir = (tp - Tool.Parent.Torso.Position).unit
  577. local spawnPos = Tool.Parent.Torso.Position
  578. local pos = spawnPos + (dir * 1)
  579. script.Gyro.Value.cframe = CFrame.new(pos, pos + dir)
  580. end
  581. end
  582.  
  583. onEquipped=function(mouse)
  584. for i,k in pairs(Tool.Parent.Torso:GetChildren()) do
  585. if k:IsA("BodyGyro") then
  586. k.Parent=nil
  587. end
  588. end
  589. wait(0.1)
  590. script.Gyro.Value.Parent = Tool.Parent:findFirstChild("Torso")
  591. script.Gyro.Value.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  592. mouse.Move:connect(function() onMouseMove(mouse) end)
  593. end
  594.  
  595. onUnequipped=function()
  596. script.Gyro.Value.Parent = nil
  597. wait(0.01)
  598. for i,k in pairs(Tool.Parent.Torso:GetChildren()) do
  599. if k:IsA("BodyGyro") then
  600. k.Parent=nil
  601. end
  602. end
  603. end
  604.  
  605. Tool.Equipped:connect(onEquipped)
  606. Tool.Unequipped:connect(onUnequipped)
  607. end))
  608. ObjectValue13.Name = "Gyro"
  609. ObjectValue13.Parent = LocalScript12
  610. for i,v in pairs(mas:GetChildren()) do
  611. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  612. pcall(function() v:MakeJoints() end)
  613. end
  614. mas:Destroy()
  615. for i,v in pairs(cors) do
  616. spawn(function()
  617. pcall(v)
  618. end)
  619. end
Add Comment
Please, Sign In to add comment