lolita5432

shotgun laser

Dec 17th, 2017
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.76 KB | None | 0 0
  1. --Made by intensivelake39/bad#5159
  2. function sandbox(var,func)
  3. local env = getfenv(func)
  4. local newenv = setmetatable({},{
  5. __index = function(self,k)
  6. if k=="script" then
  7. return var
  8. else
  9. return env[k]
  10. end
  11. end,
  12. })
  13. setfenv(func,newenv)
  14. return func
  15. end
  16. cors = {}
  17. mas = Instance.new("Model",game:GetService("Lighting"))
  18. Tool0 = Instance.new("Tool")
  19. Part1 = Instance.new("Part")
  20. SpecialMesh2 = Instance.new("SpecialMesh")
  21. Sound3 = Instance.new("Sound")
  22. Sound4 = Instance.new("Sound")
  23. PointLight5 = Instance.new("PointLight")
  24. Weld6 = Instance.new("Weld")
  25. Weld7 = Instance.new("Weld")
  26. Weld8 = Instance.new("Weld")
  27. LocalScript9 = Instance.new("LocalScript")
  28. Sound10 = Instance.new("Sound")
  29. LocalScript11 = Instance.new("LocalScript")
  30. Part12 = Instance.new("Part")
  31. SpecialMesh13 = Instance.new("SpecialMesh")
  32. PointLight14 = Instance.new("PointLight")
  33. Script15 = Instance.new("Script")
  34. Script16 = Instance.new("Script")
  35. Tool0.Name = "LaserShotGun"
  36. Tool0.Parent = mas
  37. Tool0.TextureId = "http://www.roblox.com/asset?id=130093050"
  38. Tool0.GripForward = Vector3.new(-0.376944453, -0.000461966498, -0.926235735)
  39. Tool0.GripPos = Vector3.new(0, 0.200000003, 0.25000003)
  40. Tool0.GripRight = Vector3.new(0.926235914, -0.000188003658, -0.376944423)
  41. Tool0.GripUp = Vector3.new(1.45519152e-11, 0.999999881, -0.000498756883)
  42. Tool0.ToolTip = "Hyperlaser shotgun!"
  43. Tool0.CanBeDropped = false
  44. Part1.Name = "Handle"
  45. Part1.Parent = Tool0
  46. Part1.Rotation = Vector3.new(-180, 0, -180)
  47. Part1.CanCollide = false
  48. Part1.FormFactor = Enum.FormFactor.Custom
  49. Part1.Size = Vector3.new(0.580000222, 1.34000099, 4.48000145)
  50. Part1.CFrame = CFrame.new(16.2899971, 0.670000017, -30.1599998, -0.999997616, 9.05775108e-12, -1.88592058e-08, -9.13322282e-12, 0.999997377, 6.28057464e-08, -1.53668083e-08, -6.28641601e-08, -0.999999821)
  51. Part1.BottomSurface = Enum.SurfaceType.Smooth
  52. Part1.TopSurface = Enum.SurfaceType.Smooth
  53. Part1.Position = Vector3.new(16.2899971, 0.670000017, -30.1599998)
  54. Part1.Orientation = Vector3.new(0, -180, 0)
  55. SpecialMesh2.Parent = Part1
  56. SpecialMesh2.MeshId = "http://www.roblox.com/asset?id=130099641"
  57. SpecialMesh2.Scale = Vector3.new(1, 0.75, 1.5)
  58. SpecialMesh2.TextureId = "http://www.roblox.com/asset?id=130093033"
  59. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  60. SpecialMesh2.Scale = Vector3.new(1, 0.75, 1.5)
  61. Sound3.Name = "Fire"
  62. Sound3.Parent = Part1
  63. Sound3.Pitch = 0.5
  64. Sound3.SoundId = "http://www.roblox.com/asset?id=130113322"
  65. Sound3.Volume = 1
  66. Sound4.Name = "Reload"
  67. Sound4.Parent = Part1
  68. Sound4.Pitch = 0.5
  69. Sound4.SoundId = "http://www.roblox.com/asset?id=130113370"
  70. PointLight5.Parent = Part1
  71. PointLight5.Color = Color3.new(0, 1, 1)
  72. PointLight5.Range = 6
  73. PointLight5.Color = Color3.new(0, 1, 1)
  74. Weld6.Parent = Part1
  75. Weld6.C0 = CFrame.new(0, 0, 0, -3.17205462e-08, 2.98023188e-08, 0.999999821, 4.42590249e-08, 0.999999821, -2.98023295e-08, -1, 4.42590107e-08, -3.17205746e-08)
  76. Weld6.C1 = CFrame.new(0, 0, 0, -3.17205462e-08, 2.98023188e-08, 0.999999821, 4.42590249e-08, 0.999999821, -2.98023295e-08, -1, 4.42590107e-08, -3.17205746e-08)
  77. Weld6.Part0 = Part1
  78. Weld6.Part1 = Part1
  79. Weld7.Parent = Part1
  80. Weld7.C0 = CFrame.new(0, 0, 0, -0.823671401, 0.00976598449, 0.566983223, 0.566961288, -0.00514982874, 0.823728263, 0.0109643862, 0.999939024, -0.00129515026)
  81. Weld7.C1 = CFrame.new(0, 0, 0, -0.823671401, 0.00976598449, 0.566983223, 0.566961288, -0.00514982874, 0.823728263, 0.0109643862, 0.999939024, -0.00129515026)
  82. Weld7.Part0 = Part1
  83. Weld7.Part1 = Part1
  84. Weld8.Parent = Part1
  85. Weld8.C0 = CFrame.new(0, 0, 0, -0.823671401, 0.00976598449, 0.566983223, 0.566961288, -0.00514982874, 0.823728263, 0.0109643862, 0.999939024, -0.00129515026)
  86. Weld8.C1 = CFrame.new(-0.399999499, 0, 1.1920929e-07, -0.823670983, 0.00976601522, 0.566982925, 0.56696099, -0.00514967833, 0.823727846, 0.0109643312, 0.999939024, -0.00129529205)
  87. Weld8.Part0 = Part1
  88. Weld8.Part1 = Part12
  89. LocalScript9.Name = "ToolScript"
  90. LocalScript9.Parent = Tool0
  91. table.insert(cors,sandbox(LocalScript9,function()
  92. -----------------
  93. --| Constants |--
  94. -----------------
  95.  
  96. local SHOT_SPEED =250
  97. local SHOT_TIME = 100
  98.  
  99. local NOZZLE_OFFSET = Vector3.new(0, 0.4, -1.1)
  100.  
  101. -----------------
  102. --| Variables |--
  103. -----------------
  104.  
  105. local PlayersService = Game:GetService('Players')
  106. local DebrisService = Game:GetService('Debris')
  107.  
  108. local Tool = script.Parent
  109. local Handle = Tool:WaitForChild('Handle')
  110.  
  111. local FireSound = Handle:WaitForChild('Fire')
  112. local ReloadSound = Handle:WaitForChild('Reload')
  113. local HitFadeSound = script:WaitForChild('HitFade')
  114.  
  115. local PointLight = Handle:WaitForChild('PointLight')
  116.  
  117. local Character = nil
  118. local Humanoid = nil
  119. local Player = nil
  120.  
  121. local BaseShot = nil
  122.  
  123. -----------------
  124. --| Functions |--
  125. -----------------
  126.  
  127. -- Returns a character ancestor and its Humanoid, or nil
  128. local function FindCharacterAncestor(subject)
  129. if subject and subject ~= Workspace then
  130. local humanoid = subject:FindFirstChild('Humanoid')
  131. if humanoid then
  132. return subject, humanoid
  133. else
  134. return FindCharacterAncestor(subject.Parent)
  135. end
  136. end
  137. return nil
  138. end
  139.  
  140. -- Removes any old creator tags and applies new ones to the specified target
  141. local function ApplyTags(target)
  142. while target:FindFirstChild('creator') do
  143. target.creator:Destroy()
  144. end
  145.  
  146. local creatorTag = Instance.new('ObjectValue')
  147. creatorTag.Value = Player
  148. creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
  149.  
  150. local iconTag = Instance.new('StringValue')
  151. iconTag.Value = Tool.TextureId
  152. iconTag.Name = 'icon'
  153.  
  154. iconTag.Parent = creatorTag
  155. creatorTag.Parent = target
  156. DebrisService:AddItem(creatorTag, 4)
  157. end
  158.  
  159. -- Returns all objects under instance with Transparency
  160. local function GetTransparentsRecursive(instance, partsTable)
  161. local partsTable = partsTable or {}
  162. for _, child in pairs(instance:GetChildren()) do
  163. if child:IsA('BasePart') or child:IsA('Decal') then
  164. table.insert(partsTable, child)
  165. end
  166. GetTransparentsRecursive(child, partsTable)
  167. end
  168. return partsTable
  169. end
  170.  
  171. local function SelectionBoxify(instance)
  172. local selectionBox = Instance.new('SelectionBox')
  173. selectionBox.Adornee = instance
  174. selectionBox.Color = BrickColor.new('Toothpaste')
  175. selectionBox.Parent = instance
  176. return selectionBox
  177. end
  178.  
  179. local function Light(instance)
  180. local light = PointLight:Clone()
  181. light.Range = light.Range + 2
  182. light.Parent = instance
  183. end
  184.  
  185. local function FadeOutObjects(objectsWithTransparency, fadeIncrement)
  186. repeat
  187. local lastObject = nil
  188. for _, object in pairs(objectsWithTransparency) do
  189. object.Transparency = object.Transparency + fadeIncrement
  190. lastObject = object
  191. end
  192. wait()
  193. until lastObject.Transparency >= 1 or not lastObject
  194. end
  195.  
  196. local function Dematerialize(character, humanoid, firstPart)
  197. humanoid.WalkSpeed = 0
  198.  
  199. local parts = {}
  200. for _, child in pairs(character:GetChildren()) do
  201. if child:IsA('BasePart') then
  202. child.Anchored = true
  203. table.insert(parts, child)
  204. elseif child:IsA('LocalScript') or child:IsA('Script') then
  205. child:Destroy()
  206. end
  207. end
  208.  
  209. local selectionBoxes = {}
  210.  
  211. local firstSelectionBox = SelectionBoxify(firstPart)
  212. Light(firstPart)
  213. wait(0.05)
  214.  
  215. for _, part in pairs(parts) do
  216. if part ~= firstPart then
  217. table.insert(selectionBoxes, SelectionBoxify(part))
  218. Light(part)
  219. end
  220. end
  221.  
  222. local objectsWithTransparency = GetTransparentsRecursive(character)
  223. FadeOutObjects(objectsWithTransparency, 0.1)
  224.  
  225. wait(0.5)
  226.  
  227. humanoid.Health = 0
  228. DebrisService:AddItem(character, 2)
  229.  
  230. local fadeIncrement = 0.05
  231. Delay(0.2, function()
  232. FadeOutObjects({firstSelectionBox}, fadeIncrement)
  233. if character then
  234. character:Destroy()
  235. end
  236. end)
  237. FadeOutObjects(selectionBoxes, fadeIncrement)
  238. end
  239.  
  240. local function OnTouched(shot, otherPart)
  241. local character, humanoid = FindCharacterAncestor(otherPart)
  242. if character and humanoid and character ~= Character then
  243. ApplyTags(humanoid)
  244. if shot then
  245. local hitFadeSound = shot:FindFirstChild(HitFadeSound.Name)
  246. if hitFadeSound then
  247. hitFadeSound.Parent = humanoid.Torso
  248. hitFadeSound:Play()
  249. end
  250. shot:Destroy()
  251. end
  252. Dematerialize(character, humanoid, otherPart)
  253. end
  254. end
  255.  
  256. local function OnEquipped()
  257. Character = Tool.Parent
  258. Humanoid = Character:WaitForChild('Humanoid')
  259. Player = PlayersService:GetPlayerFromCharacter(Character)
  260. end
  261.  
  262. local function OnActivated()
  263. if Tool.Enabled and Humanoid.Health > 0 then
  264. Tool.Enabled = false
  265.  
  266. FireSound:Play()
  267.  
  268. local handleCFrame = Handle.CFrame
  269. local firingPoint = handleCFrame.p + handleCFrame:vectorToWorldSpace(NOZZLE_OFFSET)
  270. for i=1, 25 do
  271. local target=Humanoid.TargetPoint
  272. target = CFrame.Angles((0.5 - math.random()) * 2 * (math.random()*.04),
  273. (0.5 - math.random()) * 2 * (math.random()*.04),
  274. (0.5 - math.random()) * 2 * (math.random()*.04)) * target
  275.  
  276. local shotCFrame = CFrame.new(firingPoint, target)
  277.  
  278.  
  279. local laserShotClone = BaseShot:Clone()
  280. laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector * (BaseShot.Size.Z / 2))
  281. local bodyVelocity = Instance.new('BodyVelocity')
  282. bodyVelocity.velocity = shotCFrame.lookVector * SHOT_SPEED
  283. bodyVelocity.Parent = laserShotClone
  284. laserShotClone.Touched:connect(function(otherPart)
  285. OnTouched(laserShotClone, otherPart)
  286. end)
  287. DebrisService:AddItem(laserShotClone, SHOT_TIME)
  288. laserShotClone.Parent = Tool
  289. end
  290.  
  291. Tool.GripPos=Vector3.new(0,.2,-.5)
  292. Tool.GripRight=Vector3.new(0.926,.2,-0.377)
  293. wait(.1)
  294. Tool.GripPos=Vector3.new(0,.2,-0.25)
  295. Tool.GripRight=Vector3.new(0.926,.15,-0.377)
  296. wait(.1)
  297. Tool.GripPos=Vector3.new(0,0.2,0)
  298. Tool.GripRight=Vector3.new(0.926,.1,-0.377)
  299. wait(.1)
  300. Tool.GripPos=Vector3.new(0,0.2,0.125)
  301. Tool.GripRight=Vector3.new(0.926,.05,-0.377)
  302. wait(.1)
  303. Tool.GripPos=Vector3.new(0,0.2,0.25)
  304. Tool.GripRight=Vector3.new(0.926,0,-0.377)
  305. wait(.25)
  306.  
  307. ReloadSound:Play()
  308. wait(1.25) -- ReloadSound length
  309.  
  310. Tool.Enabled = true
  311. end
  312. end
  313.  
  314. local function OnUnequipped()
  315.  
  316. end
  317.  
  318. --------------------
  319. --| Script Logic |--
  320. --------------------
  321.  
  322. BaseShot = Instance.new('Part')
  323. BaseShot.Name = 'Effect'
  324. BaseShot.FormFactor = Enum.FormFactor.Custom
  325. BaseShot.Size = Vector3.new(0.2, 0.2, 3)
  326. BaseShot.CanCollide = false
  327. BaseShot.BrickColor = BrickColor.new('Toothpaste')
  328. SelectionBoxify(BaseShot)
  329. Light(BaseShot)
  330. HitFadeSound:Clone().Parent = BaseShot
  331.  
  332. Tool.Equipped:connect(OnEquipped)
  333. Tool.Unequipped:connect(OnUnequipped)
  334. Tool.Activated:connect(OnActivated)
  335.  
  336. end))
  337. Sound10.Name = "HitFade"
  338. Sound10.Parent = LocalScript9
  339. Sound10.SoundId = "http://www.roblox.com/asset?id=130113415"
  340. LocalScript11.Name = "MouseIcon"
  341. LocalScript11.Parent = Tool0
  342. table.insert(cors,sandbox(LocalScript11,function()
  343. local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
  344. local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
  345.  
  346. local Tool = script.Parent
  347.  
  348. local Mouse = nil
  349.  
  350. local function UpdateIcon()
  351. if Mouse then
  352. Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
  353. end
  354. end
  355.  
  356. local function OnEquipped(mouse)
  357. Mouse = mouse
  358. UpdateIcon()
  359. end
  360.  
  361. local function OnChanged(property)
  362. if property == 'Enabled' then
  363. UpdateIcon()
  364. end
  365. end
  366.  
  367. Tool.Equipped:connect(OnEquipped)
  368. Tool.Changed:connect(OnChanged)
  369.  
  370. end))
  371. Part12.Name = "Barrel2"
  372. Part12.Parent = Tool0
  373. Part12.Rotation = Vector3.new(180, 0, 180)
  374. Part12.FormFactor = Enum.FormFactor.Custom
  375. Part12.Size = Vector3.new(0.580000222, 1.34000099, 4.48000145)
  376. Part12.CFrame = CFrame.new(15.8899984, 0.670000017, -30.1599998, -0.999998212, -2.97932274e-08, 2.60770321e-08, -2.98114173e-08, 0.999998033, -1.00757461e-07, -4.09781933e-08, -1.94995664e-07, -0.999999881)
  377. Part12.BottomSurface = Enum.SurfaceType.Smooth
  378. Part12.TopSurface = Enum.SurfaceType.Smooth
  379. Part12.Position = Vector3.new(15.8899984, 0.670000017, -30.1599998)
  380. Part12.Orientation = Vector3.new(0, 180, 0)
  381. SpecialMesh13.Parent = Part12
  382. SpecialMesh13.MeshId = "http://www.roblox.com/asset?id=130099641"
  383. SpecialMesh13.Scale = Vector3.new(1, 0.75, 1.5)
  384. SpecialMesh13.TextureId = "http://www.roblox.com/asset?id=130093033"
  385. SpecialMesh13.MeshType = Enum.MeshType.FileMesh
  386. SpecialMesh13.Scale = Vector3.new(1, 0.75, 1.5)
  387. PointLight14.Parent = Part12
  388. PointLight14.Color = Color3.new(0, 1, 1)
  389. PointLight14.Range = 6
  390. PointLight14.Color = Color3.new(0, 1, 1)
  391. Script15.Name = "Weld"
  392. Script15.Parent = Tool0
  393. table.insert(cors,sandbox(Script15,function()
  394. function Weld(x,y)
  395. local W = Instance.new("Weld")
  396. W.Part0 = x
  397. W.Part1 = y
  398. local CJ = CFrame.new(x.Position)
  399. local C0 = x.CFrame:inverse()*CJ
  400. local C1 = y.CFrame:inverse()*CJ
  401. W.C0 = C0
  402. W.C1 = C1
  403. W.Parent = x
  404. end
  405.  
  406. function Get(A)
  407. if A.className == "Part" or A.className == "UnionOperation"then
  408. Weld(script.Parent.Handle, A)
  409. A.Anchored = false
  410. else
  411. local C = A:GetChildren()
  412. for i=1, #C do
  413. Get(C[i])
  414. end
  415. end
  416. end
  417.  
  418. function Finale()
  419. Get(script.Parent)
  420. end
  421.  
  422. script.Parent.Equipped:connect(Finale)
  423. script.Parent.Unequipped:connect(Finale)
  424. Finale()
  425. end))
  426. Script16.Name = "WeldArm"
  427. Script16.Parent = Tool0
  428. table.insert(cors,sandbox(Script16,function()
  429. Tool = script.Parent
  430.  
  431. local arms = nil
  432. local torso = nil
  433. local welds = {}
  434. local down = false
  435.  
  436. function Equip(mouse)
  437. wait(0.01)
  438. arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
  439. torso = Tool.Parent:FindFirstChild("Torso")
  440. if arms ~= nil and torso ~= nil then
  441. local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
  442. if sh ~= nil then
  443. local yes = true
  444. if yes then
  445. yes = false
  446. sh[1].Part1 = nil
  447. sh[2].Part1 = nil
  448. local weld1 = Instance.new("Weld")
  449. weld1.Part0 = torso
  450. weld1.Parent = torso
  451. weld1.Part1 = arms[1]
  452. weld1.C1 = CFrame.new(-.1, 1.25, .6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(10), math.rad(-90))
  453. welds[1] = weld1
  454. local weld2 = Instance.new("Weld")
  455. weld2.Part0 = torso
  456. weld2.Parent = torso
  457. weld2.Part1 = arms[2]
  458. weld2.C1 = CFrame.new(-1, -0.5, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-30), 0)
  459. welds[2] = weld2
  460. end
  461. else
  462. print("sh")
  463. end
  464. else
  465. print("arms")
  466. end
  467. end
  468.  
  469. function Unequip(mouse)
  470. if arms ~= nil and torso ~= nil then
  471. local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
  472. if sh ~= nil then
  473. local yes = true
  474. if yes then
  475. yes = false
  476. sh[1].Part1 = arms[1]
  477. sh[2].Part1 = arms[2]
  478. welds[1].Parent = nil
  479. welds[2].Parent = nil
  480. end
  481. else
  482. print("sh")
  483. end
  484. else
  485. print("arms")
  486. end
  487. end
  488.  
  489. Tool.Equipped:connect(Equip)
  490. Tool.Unequipped:connect(Unequip)
  491.  
  492. end))
  493. for i,v in pairs(mas:GetChildren()) do
  494. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  495. pcall(function() v:MakeJoints() end)
  496. end
  497. mas:Destroy()
  498. for i,v in pairs(cors) do
  499. spawn(function()
  500. pcall(v)
  501. end)
  502. end
Add Comment
Please, Sign In to add comment