Advertisement
IAmBW

Gun

Mar 21st, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.65 KB | None | 0 0
  1. name = "IAmBW"
  2. mn = "Gun1"
  3.  
  4. me = game.Players[name]
  5. char = me.Character
  6. selected = false
  7. dmg = 18
  8. bulletcols = {"New Yeller", "Bright yellow"}
  9.  
  10. if char:findFirstChild(mn,true) ~= nil then
  11.     char:findFirstChild(mn,true).Parent = nil
  12. end
  13.  
  14. function prop(part, parent, collide, tran, ref, x, y, z, color, anchor, form)
  15. part.Parent = parent
  16. part.formFactor = form
  17. part.CanCollide = collide
  18. part.Transparency = tran
  19. part.Reflectance = ref
  20. part.Size = Vector3.new(x,y,z)
  21. part.BrickColor = BrickColor.new(color)
  22. part.TopSurface = 0
  23. part.BottomSurface = 0
  24. part.Anchored = anchor
  25. part.Locked = true
  26. part:BreakJoints()
  27. end
  28.  
  29. function weld(w, p, p1, a, b, c, x, y, z)
  30. w.Parent = p
  31. w.Part0 = p
  32. w.Part1 = p1
  33. w.C1 = CFrame.fromEulerAnglesXYZ(a,b,c) * CFrame.new(x,y,z)
  34. end
  35.  
  36. mod = Instance.new("Model")
  37. mod.Name = mn
  38.  
  39. rarm = char:findFirstChild("Right Arm")
  40. larm = char:findFirstChild("Left Arm")
  41. rleg = char:findFirstChild("Right Leg")
  42. torso = char:findFirstChild("Torso")
  43. hum = char:findFirstChild("Humanoid")
  44.  
  45. --Parts--------Parts--------Parts--------Parts--------Parts--------Parts--------Parts------
  46.  
  47. main = Instance.new("Part")
  48. prop(main,mod,false,0,0,0.3,1.2,0.5,"Black",false,"Custom")
  49. hold = Instance.new("Weld")
  50. weld(hold,rarm,nil,math.pi/1.8,0,0,0,1.05,0)
  51.  
  52. main2 = Instance.new("Part")
  53. prop(main2,mod,false,0,0,0.4,1.5,0.4,"Black",false,"Custom")
  54. lol = Instance.new("Weld")
  55. weld(lol,main,main2,math.pi/2.3,0,0,0,-0.65,0.4)
  56. Instance.new("CylinderMesh",main2)
  57.  
  58. mod.Parent = char
  59.  
  60. --Arm welds----------Arm welds----------Arm welds----------Arm welds----------Arm welds--------
  61.  
  62. rb = Instance.new("Part")
  63. prop(rb,mod,false,1,0,0.1,0.1,0.1,"Black",false,"Custom")
  64. lrw = Instance.new("Weld")
  65. weld(lrw,torso,rb,0,0,0,-1.5,-0.5,0)
  66.  
  67. lb = Instance.new("Part")
  68. prop(lb,mod,false,1,0,0.1,0.1,0.1,"Black",false,"Custom")
  69. llw = Instance.new("Weld")
  70. weld(llw,torso,lb,0,0,0,1.5,-0.5,0)
  71.  
  72. rw = Instance.new("Weld")
  73. weld(rw,rb,nil,0,0,0,0,0.5,0)
  74.  
  75. lw = Instance.new("Weld")
  76. weld(lw,lb,nil,0,0,0,0,0.5,0)
  77.  
  78. hw = Instance.new("Weld")
  79. weld(hw,rleg,main,math.pi/1.2,0,0,-0.6,-0.4,0)
  80.  
  81. rist = nil
  82. lest = nil
  83.  
  84. if not script.Parent:IsA("HopperBin") then
  85.     h = Instance.new("HopperBin")
  86.     h.Name = "Gun"
  87.     h.Parent = me.Backpack
  88.     script.Parent = h
  89. end
  90.  
  91. bin = script.Parent
  92.  
  93. function selectmotion()
  94.     rw.Part1 = rarm
  95.     lw.Part1 = larm
  96.     hw.Part1 = nil
  97.     hold.Part1 = main
  98.     for i=0,90,15 do
  99.         rw.C0 = CFrame.Angles(math.rad(i),0,0) * CFrame.new(-i/180,-i/170,0)
  100.         lw.C0 = CFrame.Angles(math.rad(i/1.01),0,math.rad(i/2)) * CFrame.new(i/220,-i/70,0)
  101.         wait()
  102.     end
  103.     if rist == nil then
  104.         rist = rw.C0
  105.         lest = lw.C0
  106.     end
  107. end
  108.  
  109. function deselmotion()
  110.     for i=90,0,-15 do
  111.         rw.C0 = CFrame.Angles(math.rad(i),0,0) * CFrame.new(-i/180,-i/170,0)
  112.         lw.C0 = CFrame.Angles(math.rad(i/1.01),0,math.rad(i/2)) * CFrame.new(i/220,-i/70,0)
  113.         wait()
  114.     end
  115.     rw.Part1 = nil
  116.     lw.Part1 = nil
  117.     hw.Part1 = main
  118.     hold.Part1 = nil
  119. end
  120.  
  121. function fire(p,pos)
  122.     local dist = (p.Position - pos).magnitude
  123.     local trail = Instance.new("Part")
  124.     prop(trail,workspace,false,0,0,0.1,1,0.1,bulletcols[math.random(1,#bulletcols)],true,"Custom")
  125.     local m = Instance.new("CylinderMesh",trail)
  126.     m.Scale = Vector3.new(0.5,dist,0.5)
  127.     trail.CFrame = CFrame.new(p.Position, pos) * CFrame.Angles(math.pi/2,0,0) * CFrame.new(0,-dist/2,0)
  128.     coroutine.resume(coroutine.create(function()
  129.         for i=0,1,0.1 do
  130.             wait()
  131.             trail.Transparency = i
  132.         end
  133.         trail:remove()
  134.     end))
  135. end
  136.  
  137. function select(mouse)
  138.     selectmotion()
  139.     mouse.Button1Down:connect(function() fire(main2, mouse.Hit.p) end)
  140. end
  141.  
  142. function desel()
  143.     deselmotion()
  144. end
  145.  
  146. bin.Selected:connect(select)
  147. bin.Deselected:connect(desel)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement