proff001

M4A1

Sep 30th, 2016
137
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local plrs=game:service'Players'
  2. local ws=workspace
  3. local lt=game:service'Lighting'
  4. local db=game:service'Debris'
  5. local plr=plrs.LocalPlayer
  6. local char=plr.Character
  7. local cf=CFrame.new
  8. local ca=CFrame.Angles
  9. local cfea=CFrame.fromEulerAnglesXYZ
  10. local v3=Vector3.new
  11. local sin=math.sin
  12. local cos=math.cos
  13. local tan=math.tan
  14. local rad=math.rad
  15. local pi=math.pi
  16. local asset="http://www.roblox.com/asset/?id="
  17. local shoot=false
  18. if char:FindFirstChild('Gun')==nil then Instance.new('Model',char).Name='Gun' end
  19. if char:FindFirstChild('Crouch')==nil then Instance.new('Model',char).Name='Crouch' end
  20. local bin=Instance.new('HopperBin',plr.Backpack)
  21. bin.Name='Gun'
  22. function cleanweld(parent)
  23. for _,v in pairs(parent:children()) do
  24. if v:IsA('Weld') then
  25. v:Destroy()
  26. end
  27. end
  28. end
  29. function prop(name,parent,collide,size,position,bc)
  30. local p=Instance.new('Part',parent)
  31. p.Name=name
  32. p.formFactor='Custom'
  33. p.Size=size
  34. p.CanCollide=collide
  35. p.Position=position
  36. p.TopSurface=0
  37. p.BottomSurface=0
  38. p.BrickColor=bc
  39. return p
  40. end
  41. function weld(p0,p1,c0,c1,parent,name)
  42. local w=Instance.new('Weld',parent)
  43. w.Part0=p0
  44. w.Part1=p1
  45. w.C0=c0
  46. w.C1=c1
  47. w.Name=name
  48. return w
  49. end
  50. function ray(o,of,uni,ign,bc)
  51. local r=Ray.new(o,(of-o).unit*uni)
  52. local h,p=ws:FindPartOnRayWithIgnoreList(r,ign)
  53. if h then
  54. if h.Parent:FindFirstChild('Humanoid') then
  55. h.Parent.Humanoid:TakeDamage(25)
  56. if h.Name=='Head' then
  57. h.Parent:BreakJoints()
  58. end
  59. if h.ClassName=='Hat' then
  60. h.Parent.Humanoid:TakeDamage(25)
  61. end
  62. end
  63. end
  64. local d=(p-o).magnitude
  65. local pa=Instance.new('Part',ws)
  66. pa.Anchored=true
  67. pa.CanCollide=false
  68. pa.TopSurface=0
  69. pa.Name='RayPart'
  70. pa.BottomSurface=0
  71. pa.BrickColor=bc
  72. pa.formFactor='Custom'
  73. pa.Transparency=0.5
  74. pa.Size=v3(0.2,0.2,d)
  75. pa.CFrame=cf(p,o)*cf(0,0,-d/2)
  76. db:AddItem(pa,0.1)
  77. end
  78. function sound(id,name,pitch,vol,parent)
  79. local s=Instance.new('Sound',parent)
  80. s.Name=name
  81. s.Pitch=pitch
  82. s.Volume=vol
  83. s.SoundId=asset..tostring(id)
  84. s:Play()
  85. db:AddItem(s,0.5)
  86. end
  87. wait(0.25)
  88. cleanweld(char['Torso'])
  89. weld(char['Torso'],char['Right Arm'],cf(-0.5,0.5,0)*ca(math.rad(90),0,-math.rad(35)),cf(-1.5,0,0),char['Torso'],'rweld0')
  90. weld(char['Torso'],char['Left Arm'],cf(-0.5,0.5,0)*ca(math.rad(90),0,math.rad(10)),cf(0.5,1.1,0),char['Torso'],'lweld0')
  91. local par=prop('Body',char['Gun'],false,v3(0.5,0.5,4),char:GetModelCFrame().p,BrickColor.new('Really black'))
  92. local burn=prop('Burner',char['Gun'],false,v3(0.1,0.1,0.1),char:GetModelCFrame().p,BrickColor.new('Really black'))
  93. local grip=prop('Mag',char['Gun'],false,v3(0.2,1,0.2),char:GetModelCFrame().p,BrickColor.new('Really black'))
  94. local hold=prop('Hold',char['Gun'],false,v3(0.5,1,0.5),char:GetModelCFrame().p,BrickColor.new('Really black'))
  95. local a1=prop('Aim1',char['Gun'],false,v3(0.5,0.1,0.1),char:GetModelCFrame().p,BrickColor.new('Really black'))
  96. local a2=prop('Aim2',char['Gun'],false,v3(0.5,0.35,0.1),char:GetModelCFrame().p,BrickColor.new('Medium stone Grey'))
  97. local dot=prop('RedDot',char['Gun'],false,v3(0.1,0.1,0.1),char:GetModelCFrame().p,BrickColor.new('Bright red'))
  98. local po1=prop('Point1',char['Gun'],false,v3(0.1,0.1,0.1),char:GetModelCFrame().p,BrickColor.new('Really black'))
  99. local grip2=prop('Grip',char['Gun'],false,v3(0.2,1,0.2),char:GetModelCFrame().p,BrickColor.new('Really black'))
  100. local bar=prop('Barrel',char['Gun'],false,v3(0.2,0.2,1),char:GetModelCFrame().p,BrickColor.new('Really black'))
  101. local bar2=prop('Barrel2',char['Gun'],false,v3(0.1,0.1,0.5),char:GetModelCFrame().p,BrickColor.new('Really black'))
  102. local a3=prop('Aim3',char['Gun'],false,v3(0.25,0.1,2),char:GetModelCFrame().p,BrickColor.new('Really black'))
  103. local bar3=prop('Barrel3',char['Gun'],false,v3(0.1,0.1,0.35),char:GetModelCFrame().p,BrickColor.new('Really black'))
  104. local po2=po1:Clone()
  105. po2.Parent=char['Gun']
  106. po2.Name='Point2'
  107. local po3=po1:Clone()
  108. po3.Parent=char['Gun']
  109. po3.Name='Point3'
  110. po3.BrickColor=BrickColor.new('White')
  111. po3.Transparency=0.5
  112. local po4=po2:Clone()
  113. po4.Parent=char['Gun']
  114. po4.Name='Point4'
  115. po4.BrickColor=BrickColor.new('White')
  116. po4.Transparency=0.5
  117. Instance.new('SpecialMesh',dot).Scale=v3(0.25,0.25,0.25)
  118. local p1m=Instance.new('SpecialMesh',po1)
  119. p1m.MeshType='Brick'
  120. p1m.Scale=v3(0.25,0.5,0.25)
  121. local p2m=Instance.new('SpecialMesh',po2)
  122. p2m.MeshType='Brick'
  123. p2m.Scale=v3(0.25,0.5,0.25)
  124. local p3m=Instance.new('SpecialMesh',po3)
  125. p3m.MeshType='Brick'
  126. p3m.Scale=v3(0.25,0.25,0.25)
  127. local p4m=Instance.new('SpecialMesh',po4)
  128. p4m.MeshType='Brick'
  129. p4m.Scale=v3(0.25,0.25,0.25)
  130. local b1m=Instance.new('SpecialMesh',bar)
  131. b1m.MeshType='Brick'
  132. b1m.Scale=v3(0.25,0.25,1.5)
  133. local b2m=Instance.new('SpecialMesh',bar2)
  134. b2m.MeshType='Brick'
  135. b2m.Scale=v3(0.25,0.25,2)
  136. local b3m=Instance.new('SpecialMesh',bar3)
  137. b3m.MeshType='Brick'
  138. b3m.Scale=v3(0.35,0.35,1.5)
  139. burn.Transparency=1
  140. a2.Transparency=0.5
  141. weld(char['Torso'],par,cf(-0.4,1,-1.25),cf(),char['Torso'],'gweld0')
  142. weld(char['Torso'],grip,cf(-0.4,0.5,-2.25),cf(),char['Torso'],'grweld0')
  143. weld(char['Torso'],hold,cf(-0.4,0.75,0.75)*cfea(-math.rad(15),0,0),cf(),char['Torso'],'hweld0')
  144. weld(char['Torso'],a1,cf(-0.4,1.25,-2),cf(),char['Torso'],'aweld0')
  145. weld(char['Torso'],a2,cf(-0.4,1.5,-2),cf(),char['Torso'],'aweld1')
  146. weld(char['Torso'],dot,cf(-0.4,1.5+(0.35/10)-0.05,-2),cf(),char['Torso'],'dweld0')
  147. weld(char['Torso'],po1,cf(-0.2,1.3,-3),cf(),char['Torso'],'poweld0')
  148. weld(char['Torso'],po2,cf(-0.6,1.3,-3),cf(),char['Torso'],'poweld1')
  149. weld(char['Torso'],po3,cf(-0.2,1.375,-3),cf(),char['Torso'],'poweld2')
  150. weld(char['Torso'],po4,cf(-0.6,1.375,-3),cf(),char['Torso'],'poweld3')
  151. weld(char['Torso'],grip2,cf(-0.4,0.5,-1.5),cf(),char['Torso'],'grweld1')
  152. weld(char['Torso'],bar,cf(-0.4,1,-3),cf(),char['Torso'],'baweld0')
  153. weld(char['Torso'],bar2,cf(-0.4,1,-4),cf(),char['Torso'],'baweld1')
  154. weld(char['Torso'],a3,cf(-0.4,1.25,-1),cf(),char['Torso'],'aweld2')
  155. weld(char['Torso'],bar3,cf(-0.4,1,-4.5),cf(),char['Torso'],'baweld2')
  156. weld(char['Torso'],char['Head'],cf(0,1.5,0)*cfea(0,0,math.rad(10)),cf(),char['Torso'],'heweld0')
  157. bin.Selected:connect(function(mouse)
  158. shoot=false
  159. mouse.Button1Down:connect(function()
  160. shoot=true
  161. while shoot==true do
  162. ray(bar3.CFrame.p,mouse.Hit.p,500,{char,workspace:FindFirstChild('RayPart')},BrickColor.new('White'))
  163. sound(2760979,'gunshot',1.7,1,bar3)
  164. local bbg=Instance.new('BillboardGui',bar3)
  165. bbg.Name='GunShot'
  166. bbg.Size=UDim2.new(2,0,2,0)
  167. bbg.Adornee=bar3
  168. local img=Instance.new('ImageLabel',bbg)
  169. img.Size=UDim2.new(2,0,2,0)
  170. img.BackgroundTransparency=1
  171. img.Image='http://www.roblox.com/asset/?id=61378273'
  172. img.Position=UDim2.new(-0.5,0,-0.35,0)
  173. wait(0.1)
  174. img:Remove()
  175. end
  176. end)
  177. mouse.Button1Up:connect(function()
  178. shoot=false
  179. local smoke=Instance.new('Smoke',bar3)
  180. smoke.RiseVelocity=2.5
  181. smoke.Enabled=true
  182. smoke.Size=5
  183. smoke.Color=Color3.new(95/255,95/255,95/255)
  184. coroutine.wrap(function() wait(3) smoke:Remove() end)()
  185. end)
  186. mouse.KeyDown:connect(function(key)
  187. if key=='c' then
  188. weld(char['Torso'],char['Left Leg'],cf(),cf(-0.5,0.75,1),char['Left Leg'],'lweld1')
  189. weld(char['Torso'],char['Right Leg'],cf(),cf(0.5,0.495,1.15)*cfea(math.rad(90),0,0),char['Right Leg'],'rweld1')
  190. char['Left Leg'].CanCollide=false
  191. char['Right Leg'].CanCollide=false
  192. elseif key=='v' then
  193. cleanweld(char['Left Leg'])
  194. cleanweld(char['Right Leg'])
  195. char['Left Leg'].CanCollide=true
  196. char['Right Leg'].CanCollide=true
  197. end
  198. end)
  199. end)
RAW Paste Data