Advertisement
mathmasterphil

Long Gun

Mar 4th, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.92 KB | None | 0 0
  1. -- Created by 129K
  2.  
  3. local animations = {
  4. requip = {
  5. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(-10)) * CFrame.new(1.5, -.5, 0);
  6. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(180), 0, math.rad(-15)) * CFrame.new(1.5, -.5, 0);
  7. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(210), 0, math.rad(-40)) * CFrame.new(1.5, -.5, 0);
  8. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(180), 0, math.rad(-10)) * CFrame.new(1.5, -.5, 0);
  9. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, 0) * CFrame.new(1.5, -.5, 0);
  10. };
  11. lequip = {
  12. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(60)) * CFrame.new(-1, -.75, 0);
  13. };
  14. runequip = {
  15. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(-10)) * CFrame.new(1.5, -.5, 0);
  16. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(180), 0, math.rad(-15)) * CFrame.new(1.5, -.5, 0);
  17. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(210), 0, math.rad(-40)) * CFrame.new(1.5, -.5, 0);
  18. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(180), 0, math.rad(-10)) * CFrame.new(1.5, -.5, 0);
  19. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, 0) * CFrame.new(1.5, -.5, 0);
  20. CFrame.new(1.5, 0, 0);
  21. };
  22. rshoot = {
  23. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(170), 0, 0) * CFrame.new(1.5, -.5, 0);
  24. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, 0) * CFrame.new(1.5, -.5, 0);
  25. };
  26. lshoot = {
  27. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(170), 0, math.rad(60)) * CFrame.new(-1, -.75, 0);
  28. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(60)) * CFrame.new(-1, -.75, 0);
  29. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(80)) * CFrame.new(-.5, -.35, 0);
  30. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(60)) * CFrame.new(-1, -.75, 0);
  31. };
  32. }
  33. local player = game:GetService("Players").LocalPlayer
  34. local pmouse = player:GetMouse()
  35. local char = player.Character
  36. local bin = Instance.new("HopperBin", player.Backpack)
  37. local barrelsize = .3
  38. local handleweld = nil
  39. local temp = true
  40. local etemp = true
  41. bin.Name = "L96A1 Magnum"
  42.  
  43. function weld(part0, part1, c0, c1, parent)
  44. local w = Instance.new("Weld", parent)
  45. w.Part0 = part0
  46. w.Part1 = part1
  47. w.C0 = c0
  48. w.C1 = c1
  49. w.Name = "NewWeld"
  50. return w
  51. end
  52.  
  53. function interpolateCFrame(cf1, cf2)
  54. local t1 = {cf1:components()}
  55. local t2 = {cf2:components()}
  56. local newcf = {}
  57. for i, v in pairs(t1) do
  58. local dif = t2[i] - v
  59. if i < 4 then
  60. local newValue = nil
  61. if math.abs(dif) < .1 then
  62. newValue = t2[i]
  63. else
  64. newValue = v + ((dif/math.abs(dif)) * .1)
  65. end
  66. newcf[i] = newValue
  67. else
  68. local newValue = nil
  69. if math.abs(dif) < .1 then
  70. newValue = t2[i]
  71. else
  72. newValue = v + ((dif/math.abs(dif)) * .1)
  73. end
  74. newcf[i] = newValue
  75. end
  76. end
  77. return CFrame.new(unpack(newcf))
  78. end
  79.  
  80. function prop(name, sx, sy, sz, px, py, pz, anc, canc, col, par, mesh, meshtype, scalex, scaley, scalez, meshid, textureid)
  81. local part = Instance.new("Part", par)
  82. part.Name = name
  83. part.TopSurface = 0
  84. part.BottomSurface = 0
  85. part.formFactor = 3
  86. part.Size = Vector3.new(sx, sy, sz)
  87. part.Position = Vector3.new(px, py, pz)
  88. part.Anchored = anc
  89. part.CanCollide = canc
  90. part.BrickColor = BrickColor.new(col)
  91. if mesh then
  92. local m = Instance.new("SpecialMesh", part)
  93. m.MeshType = meshtype
  94. m.MeshId = meshid
  95. m.Scale = Vector3.new(scalex, scaley, scalez)
  96. m.TextureId = textureid
  97. end
  98. return part
  99. end
  100.  
  101. function fade(part, speed)
  102. for i = part.Transparency, 1, speed do
  103. part.Transparency = i
  104. wait()
  105. end
  106. part:Destroy()
  107. end
  108.  
  109. function clearWelds(par)
  110. for i, v in pairs(par:GetChildren()) do
  111. if v.Name == "NewWeld" and v:IsA("Weld") then
  112. v:Destroy()
  113. end
  114. end
  115. end
  116.  
  117. function sound(pitch, id, par)
  118. local s = Instance.new("Sound", par)
  119. s.Pitch = pitch
  120. s.SoundId = id
  121. return s
  122. end
  123.  
  124. function traceRay(pos, pos2, col, trans)
  125. local distance = (pos - pos2).magnitude
  126. local trace = Instance.new("Part", char)
  127. trace.Anchored = true
  128. trace.CanCollide = false
  129. trace.TopSurface = 0
  130. trace.BottomSurface = 0
  131. trace.formFactor = 3
  132. trace.Size = Vector3.new(.2, .2, distance)
  133. trace.BrickColor = BrickColor.new(col)
  134. trace.Transparency = trans
  135. trace.CFrame = CFrame.new(pos2, pos) * CFrame.new(0, 0, -distance/2)
  136. return trace
  137. end
  138.  
  139. clearWelds(char.Torso)
  140. local back1 = prop("Part1", .1, .7, .5, 0, 0, 0, false, false, "Black", char, false)
  141. local back1weld = weld(char.Torso, back1, CFrame.new(1, -2, .6) * CFrame.Angles(math.rad(90), math.rad(20), math.rad(90)), CFrame.new(), char.Torso)
  142. local back2 = prop("Part2", .1, .2, .1, 0, 0, 0, false, false, "Grime", char, false)
  143. local back2weld = weld(back1, back2, CFrame.new(0, -.25, -.35), CFrame.new(), char.Torso)
  144. local back3 = prop("Part3", .1, .5, 1, 0, 0, 0, false, false, "Grime", char, false)
  145. local back3weld = weld(back1, back3, CFrame.new(0, .1, -.75), CFrame.new(), char.Torso)
  146. local back4 = prop("Part4", .1, .1, 1, 0, 0, 0, false, false, "Grime", char, false)
  147. local back4weld = weld(back3, back4, CFrame.new(0, .3, 0), CFrame.new(), char.Torso)
  148. local back5 = prop("Part5", .1, .1, .7, 0, 0, 0, false, false, "Grime", char, false)
  149. local back5weld = weld(back1, back5, CFrame.new(0, .4, -1.6), CFrame.new(), char.Torso)
  150. local trigger1 = prop("Part6", .1, .1, .6, 0, 0, 0, false, false, "Grime", char, false)
  151. local trigger1weld = weld(back4, trigger1, CFrame.new(0, -.6, -.4) * CFrame.Angles(-math.rad(30), 0, 0), CFrame.new(), char.Torso)
  152. local trigger2 = prop("Part7", .1, .1, .5, 0, 0, 0, false, false, "Grime", char, false)
  153. local trigger2weld = weld(back4, trigger2, CFrame.new(0, -.675, -.8) * CFrame.Angles(math.rad(15), 0, 0), CFrame.new(), char.Torso)
  154. local trigger3 = prop("Part8", .1, .1, .7, 0, 0, 0, false, false, "Grime", char, false)
  155. local trigger3weld = weld(back4, trigger3, CFrame.new(0, -.4, -.95) * CFrame.Angles(math.rad(90), 0, 0), CFrame.new(), char.Torso)
  156. local middle1 = prop("Part9", .1, .1, 1, 0, 0, 0, false, false, "Black", char, true, "Brick", .1, .0, .1, "", "") -- dis
  157. local middle1weld = weld(back5, middle1, CFrame.new(0, .05, -.8), CFrame.new(), char.Torso)
  158. local trigframe = prop("Part10", .1, .3, .3, 0, 0, 0, false, false, "Grime", char, true, "FileMesh", .3, .3, .3, "http://www.roblox.com/asset/?id=3270017", "")
  159. local trigframeweld = weld(back5, trigframe, CFrame.new(0, -.2, -.3) * CFrame.Angles(0, math.rad(90), 0), CFrame.new(), char.Torso)
  160. local middle2 = prop("Part11", .1, .3, 2, 0, 0, 0, false, false, "Grime", char, false)
  161. local middle2weld = weld(middle1, middle2, CFrame.new(0, -.1, -.4), CFrame.new(), char.Torso)
  162. local barrel = prop("Part12", .1, .1, 4, 0, 0, 0, false, false, "Black", char, true, "Brick", .5, .5, 1, "", "")
  163. local barrelweld = weld(middle1, barrel, CFrame.new(0, -.05, -2), CFrame.new(), char.Torso)
  164. local barrel2 = prop("Part13", barrelsize, 2, barrelsize, 0, 0, 0, false, false, "Black", char, false) Instance.new("CylinderMesh", barrel2)
  165. local barrel2weld = weld(barrel, barrel2, CFrame.new(0, 0, -2.5) * CFrame.Angles(math.rad(90), 0, 0), CFrame.new(), char.Torso)
  166. local scope1 = prop("Part14", .1, .2, .1, 0, 0, 0, false, false, "Black", char, true, "Brick", .5, .5, .5, "", "")
  167. local scope1weld = weld(middle1, scope1, CFrame.new(0, .1, .25), CFrame.new(), char.Torso)
  168. local scope2 = prop("Part14", .1, .2, .1, 0, 0, 0, false, false, "Black", char, true, "Brick", .5, .5, .5, "", "")
  169. local scope2weld = weld(middle1, scope2, CFrame.new(0, .1, -.25), CFrame.new(), char.Torso)
  170. local scope3 = prop("Part15", .1, 1.5, .1, 0, 0, 0, false, false, "Black", char, false) Instance.new("CylinderMesh", scope3)
  171. local scope3weld = weld(middle1, scope3, CFrame.new(0, .2, 0) * CFrame.Angles(math.rad(90), 0, 0), CFrame.new(), char.Torso)
  172. local scope4 = prop("Part16", .2, .3, .2, 0, 0, 0, false, false, "Black", char, true, "FileMesh", .2, .3, .2, "http://www.roblox.com/asset/?id=1033714", "")
  173. local scope4weld = weld(middle1, scope4, CFrame.new(0, .2, .7) * CFrame.Angles(math.rad(270), 0, 0), CFrame.new(), char.Torso)
  174. local scope5 = prop("Part17", .3, .35, .3, 0, 0, 0, false, false, "Black", char, true, "FileMesh", .3, .35, .3, "http://www.roblox.com/asset/?id=1033714", "")
  175. local scope5weld = weld(middle1, scope5, CFrame.new(0, .2, -.7) * CFrame.Angles(math.rad(-270), 0, 0), CFrame.new(), char.Torso)
  176. local rarmweld = weld(char.Torso, nil, CFrame.new(1.5, 0, 0), CFrame.new(), char.Torso)
  177. local larmweld = weld(char.Torso, nil, CFrame.new(-1.5, 0, 0), CFrame.new(), char.Torso)
  178. local gyro = Instance.new("BodyGyro", char.Torso)
  179. gyro.P = 10000
  180. gyro.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  181. pmouse.Move:connect(function()
  182. gyro.cframe = CFrame.new(char.Torso.Position, Vector3.new(pmouse.Hit.p.X, char.Torso.Position.Y, pmouse.Hit.p.Z))
  183. end)
  184.  
  185.  
  186. function onEquip(mouse)
  187. repeat wait() until etemp and temp
  188. etemp = false
  189. rarmweld.Part1 = char["Right Arm"]
  190. local frame = 1
  191. coroutine.wrap(function()
  192. while rarmweld and animations.requip[frame] do
  193. rarmweld.C0 = interpolateCFrame(rarmweld.C0, animations.requip[frame])
  194. if rarmweld.C0 == animations.requip[frame] then
  195. frame = frame + 1
  196. else
  197. wait()
  198. end
  199. end
  200. end)()
  201. repeat wait() until frame == 3
  202. back1weld.Part0 = nil
  203. handleweld = weld(char["Right Arm"], back1, CFrame.new(-.5, 1, -.3) * CFrame.Angles(math.rad(270), 0, 0), CFrame.new(), char.Torso)
  204. repeat wait() until frame == 5
  205. larmweld.Part1 = char["Left Arm"]
  206. local frame2 = 1
  207. coroutine.wrap(function()
  208. while larmweld and animations.lequip[frame2] do
  209. larmweld.C0 = interpolateCFrame(larmweld.C0, animations.lequip[frame2])
  210. if larmweld.C0 == animations.lequip[frame2] then
  211. frame2 = frame2 + 1
  212. else
  213. wait()
  214. end
  215. end
  216. etemp = true
  217. end)()
  218. repeat wait() until frame == 6
  219.  
  220.  
  221. mouse.Button1Down:connect(function()
  222. if not temp then return end
  223. temp = false
  224. local frame3 = 1
  225. coroutine.wrap(function()
  226. while rarmweld and animations.rshoot[frame3] do
  227. rarmweld.C0 = interpolateCFrame(rarmweld.C0, animations.rshoot[frame3])
  228. if rarmweld.C0 == animations.rshoot[frame3] then
  229. frame3 = frame3 + 1
  230. else
  231. wait()
  232. end
  233. end
  234. end)()
  235. local frame4 = 1
  236. coroutine.wrap(function()
  237. while larmweld and animations.lshoot[frame4] do
  238. larmweld.C0 = interpolateCFrame(larmweld.C0, animations.lshoot[frame4])
  239. if larmweld.C0 == animations.lshoot[frame4] then
  240. frame4 = frame4 + 1
  241. else
  242. wait()
  243. end
  244. end
  245. wait(.1)
  246. temp = true
  247. end)()
  248. local ray = Ray.new(barrel2.Position, (mouse.Hit.p - barrel2.Position).unit * 500)
  249. sound(1, "http://roblox.com/asset/?id=10209875", barrel2):play()
  250. local hit, pos = workspace:FindPartOnRay(ray, char)
  251. if hit and hit.Parent:FindFirstChild("Humanoid") then
  252. local dmg = math.random(70, 100)
  253. if hit.Name ~= "Head" then
  254. hit.Parent.Humanoid:TakeDamage(dmg)
  255. hit.Parent.Humanoid.Sit = true
  256. else
  257. hit.Parent:BreakJoints()
  258. sound(1, "http://www.roblox.com/asset/?id=1876552", workspace):play()
  259. end
  260. if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) == nil then return end
  261. local bl = Instance.new("Part", workspace)
  262. bl.Name = "Blood"
  263. bl.BrickColor = BrickColor.new("Really red")
  264. bl.FormFactor = 3
  265. bl.TopSurface = 0
  266. bl.BottomSurface = 0
  267. bl.Size = Vector3.new(1, .1, 1)
  268. bl.Position = hit.Parent.Head.Position + Vector3.new(0, 3, 0)
  269. local bbg = Instance.new("BillboardGui", bl)
  270. bbg.Adornee = bl
  271. bbg.Size = UDim2.new(1, 0, 1, 0)
  272. bbg.StudsOffset = Vector3.new(0, 1, 0)
  273. local txt = Instance.new("TextLabel", bbg)
  274. txt.Position = UDim2.new(0.5, 0, 0.5, 0)
  275. txt.FontSize = "Size14"
  276. txt.TextColor3 = Color3.new(1, 1, 1)
  277. txt.Text = hit.Name ~= "Head" and dmg or "HEADSHOT"
  278. coroutine.wrap(fade)(bl, 0.005)
  279. end
  280. if hit and hit.Parent:IsA("Hat") then
  281. hit:BreakJoints()
  282. end
  283. Spawn(function()
  284. local tr = traceRay(barrel2.Position, pos, "White", .5)
  285. fade(tr, .01)
  286. end)
  287. repeat wait() until frame4 == 3
  288. sound(1, "http://roblox.com/asset/?id=10209881", middle2):play()
  289. end)
  290.  
  291.  
  292. end
  293.  
  294. function onUnequip()
  295. repeat wait() until etemp and temp
  296. etemp = false
  297. local frame = 1
  298. coroutine.wrap(function()
  299. while rarmweld and animations.runequip[frame] do
  300. rarmweld.C0 = interpolateCFrame(rarmweld.C0, animations.runequip[frame])
  301. if rarmweld.C0 == animations.runequip[frame] then
  302. frame = frame + 1
  303. else
  304. wait()
  305. end
  306. end
  307. etemp = true
  308. end)()
  309. coroutine.wrap(function()
  310. while larmweld do
  311. larmweld.C0 = interpolateCFrame(larmweld.C0, CFrame.new(-1.5, 0, 0))
  312. if larmweld.C0 == CFrame.new(-1.5, 0, 0) then
  313. break
  314. else
  315. wait()
  316. end
  317. end
  318. end)()
  319. repeat wait() until frame == 4
  320. handleweld:Remove()
  321. back1weld:Remove()
  322. back1weld = weld(char.Torso, back1, CFrame.new(1, -2, .6) * CFrame.Angles(math.rad(90), math.rad(20), math.rad(90)), CFrame.new(), char.Torso)
  323. repeat wait() until frame == 7
  324. rarmweld.Part1 = nil
  325. larmweld.Part1 = nil
  326. end
  327.  
  328. bin.Selected:connect(onEquip)
  329. bin.Deselected:connect(onUnequip)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement