Advertisement
recalculated

Lua Laser EDIT

Apr 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print("EDIT BY xMTSxClyde")
  2. function snapToTorso(pos)
  3.     local list = game.Workspace:children()
  4.     local torso = nil
  5.     local dist = 100
  6.     local temp = nil
  7.     local human = nil
  8.     local temp2 = nil
  9.     for x = 1, #list do
  10.         temp2 = list[x]
  11.         if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  12.             temp = temp2:findFirstChild("Torso")
  13.             human = temp2:findFirstChild("Humanoid")
  14.             if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  15.                 if (temp.Position - pos).magnitude < dist then
  16.                     torso = temp
  17.                     dist = (temp.Position - pos).magnitude
  18.                     annihilate()
  19.                 end
  20.             end
  21.         end
  22.     end
  23.     return torso
  24. end
  25.  
  26. function annihilate(gun,targ)
  27. pcall(function() p:remove() end)
  28. p = Instance.new("Part")
  29. p.BrickColor = BrickColor.new(45)
  30. p.Anchored = true
  31. p.CanCollide = false
  32. p.formFactor = "Plate"
  33. p.Size = Vector3.new(1,0.4,1)
  34. p.TopSurface = "Smooth"
  35. p.BottomSurface = "Smooth"
  36. local sm = Instance.new("SpecialMesh")
  37. sm.MeshType = "Sphere"
  38. sm.Parent = p
  39. local mag = (gun.Position - targ).magnitude
  40. local aim = CFrame.new(gun.Position,targ)
  41. p.CFrame = aim + (aim.lookVector * (mag / 2))
  42. sm.Scale = Vector3.new(0.2,0.2,mag )
  43. p.Parent = workspace
  44. coroutine.resume(coroutine.create(function()
  45. wait(0.3)
  46. pcall(function() p:remove() end)
  47. end))
  48. end
  49. laser(script.Parent.Shooter,torso)
  50. local ex = Instance.new("Explosion")
  51. ex.Position = torso
  52. ex.BlastRadius = 999999
  53. ex.Parent = workspace
  54. end)
  55. end)
  56. <eof>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement