XLuke

AK47

Dec 8th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.54 KB | None | 0 0
  1. -- Made by DoogleFox, don't care what people say.. It's the truth.
  2.  
  3. bin = Instance.new("Tool")
  4. bin.Name = "Sniper"
  5. bin.Parent = game:service("Players").LocalPlayer.Backpack
  6. script.Parent = bin
  7.  
  8. local CrouchingAccuracy = 0
  9. local StandingAccuracy = 2
  10. local Accuracy = StandingAccuracy
  11. local mindmg = 60
  12. local maxdmg = 90
  13. local thecrouchwalkspeed = 16
  14. local crouchingwalkspeed = 4
  15. local AntiTK = false
  16. local MaxAmmo = 8080
  17. local AmmoPerClip = 3
  18. local ShootSpeed = 1.1
  19. local ShotsPerAmmo = 1
  20.  
  21. haz = Instance.new("Part", bin)
  22. haz.formFactor = "Custom"
  23. haz.Name = "Handle2"
  24. haz.Size = Vector3.new(0.5,0.5,0.5)
  25. haz.BrickColor = BrickColor.new("Black")
  26. haz.Locked = true
  27. haz.CanCollide = true
  28. haz.Anchored = false
  29. haz.TopSurface = 0
  30. haz.BottomSurface = 0
  31. mesh = Instance.new("SpecialMesh", haz)
  32. mesh.MeshId = "http://www.roblox.com/asset/?id=2761723"
  33. -- mesh.TextureId = "http://www.roblox.com/asset/?id=6465264"
  34. mesh.Scale = Vector3.new(0.55,0.55,0.45)
  35.  
  36. han = Instance.new("Part", bin)
  37. han.formFactor = "Custom"
  38. han.Name = "Handle"
  39. han.Size = Vector3.new(0.5,1.2,2.5)
  40. han.BrickColor = BrickColor.new("Royal purple")
  41. han.Locked = true
  42. han.CanCollide = true
  43. han.Anchored = false
  44. han.TopSurface = 0
  45. han.BottomSurface = 0
  46. han.Transparency = 1
  47.  
  48. local Joint1
  49. local Joint2
  50. local Joint3
  51. local Joint4
  52. local Torsoz = bin.Parent.Parent.Character.Torso
  53. local LA = bin.Parent.Parent.Character:findFirstChild("Left Arm")
  54. local RA = bin.Parent.Parent.Character:findFirstChild("Right Arm")
  55. local LL = bin.Parent.Parent.Character:findFirstChild("Left Leg")
  56. local RL = bin.Parent.Parent.Character:findFirstChild("Right Leg")
  57. local LeftJoint = Torsoz:findFirstChild("Left Shoulder")
  58. local RightJoint = Torsoz:findFirstChild("Right Shoulder")
  59. local LeftJoint2 = Torsoz:findFirstChild("Left Hip")
  60. local RightJoint2 = Torsoz:findFirstChild("Right Hip")
  61. local NeckJoint = Torsoz:findFirstChild("Neck")
  62. local GunWeld
  63. local PlayGui = bin.Parent.Parent.PlayerGui
  64.  
  65. local CurrentAmmo = Instance.new("NumberValue")
  66. CurrentAmmo.Name = "CurrentAmmo"
  67. CurrentAmmo.Value = MaxAmmo
  68. local CurrentAmmoClip = Instance.new("NumberValue")
  69. CurrentAmmoClip.Name = "CurrentAmmoInClip"
  70. CurrentAmmoClip.Value = AmmoPerClip
  71.  
  72. ----------------------------------------------- Gui ----------------------------------------------
  73. local gui = Instance.new("ScreenGui")
  74. gui.Name = "Ammo Gui"
  75. local t = Instance.new("TextLabel", gui)
  76. t.Name = "Bak"
  77. t.Text = ""
  78. t.BackgroundColor = BrickColor.new("Really black")
  79. t.TextColor = BrickColor.new("White")
  80. t.Position = UDim2.new(0.45,0,0.82,0)
  81. t.Size = UDim2.new(0.1,0,0.045,0)
  82. t.BorderColor = BrickColor.new("Really red")
  83. t.FontSize = 4
  84. local t3 = t:Clone()
  85. t2 = t:Clone()
  86. t3.Parent = t
  87. t3.Name = "Title"
  88. t3.Size = UDim2.new(1,0,-0.6,0)
  89. t3.Text = ""
  90. t3.Position = UDim2.new(0,0,0,0)
  91. t2.Parent = t
  92. t2.Name = "Front"
  93. t2.BorderColor = BrickColor.new("Dark stone grey")
  94. t2.Size = UDim2.new(0.9,0,0.9)
  95. t2.Position = UDim2.new(0.05,0,0.05,0)
  96. t2.Text = CurrentAmmoClip.Value .. " / " .. CurrentAmmo.Value
  97. t4 = t2:Clone()
  98. t4.Parent = t3
  99. t4.Text = "Ammo"
  100. coroutine.resume(coroutine.create(function()
  101. CurrentAmmoClip.Changed:connect(function()
  102. if CurrentAmmoClip.Value < 0 then
  103. CurrentAmmoClip.Value = 0
  104. end
  105. if CurrentAmmoClip.Value > AmmoPerClip then
  106. CurrentAmmoClip.Value = AmmoPerClip
  107. end
  108. if CurrentAmmo.Value > MaxAmmo then
  109. CurrentAmmo.Value = MaxAmmo
  110. end
  111. if CurrentAmmo.Value < 0 then
  112. CurrentAmmo.Value = 0
  113. end
  114. t2.Text = CurrentAmmoClip.Value .. " / " .. CurrentAmmo.Value
  115. end)
  116. end))
  117. coroutine.resume(coroutine.create(function()
  118. CurrentAmmo.Changed:connect(function()
  119. if CurrentAmmoClip.Value < 0 then
  120. CurrentAmmoClip.Value = 0
  121. end
  122. if CurrentAmmoClip.Value > AmmoPerClip then
  123. CurrentAmmoClip.Value = AmmoPerClip
  124. end
  125. if CurrentAmmo.Value > MaxAmmo then
  126. CurrentAmmo.Value = MaxAmmo
  127. end
  128. if CurrentAmmo.Value < 0 then
  129. CurrentAmmo.Value = 0
  130. end
  131. t2.Text = CurrentAmmoClip.Value .. " / " .. CurrentAmmo.Value
  132. end)
  133. end))
  134.  
  135. ------------------------------------------------------------------------------------------------
  136.  
  137. function PlaySound(ID, pit, vol)
  138. local f = Instance.new("Sound")
  139. f.Parent = game:service("Players").LocalPlayer.Character.Head
  140. f.Name = "Fire"
  141. f.SoundId = ID
  142. f.Looped = false
  143. f.Archivable = true
  144. f.PlayOnRemove = false
  145. f.Pitch = pit
  146. f.Volume = vol
  147. f:Play()
  148. game:service("Debris"):AddItem(f, 2)
  149. end
  150.  
  151. local Down = Instance.new("NumberValue")
  152. Down.Name = "IsDown"
  153. local ReloadReady = true
  154. function Shoot(mouse)
  155. local pos1z = (haz.Position + Vector3.new(0,0.3,0)) + (haz.CFrame.lookVector * 2.55)
  156. local tempos = (CFrame.new(pos1z, mouse.Hit.p) * CFrame.Angles((math.random(-Accuracy, Accuracy)/100),math.random(-Accuracy, Accuracy)/100,math.random(-Accuracy, Accuracy)/100))
  157. local pos2z = mouse.Hit.p
  158. local ray = Ray.new(pos1z, tempos.lookVector*850)
  159. local hitz, enz = workspace:findPartOnRay(ray, Torsoz.Parent)
  160. local line = Instance.new("Part", bin)
  161. line.Anchored = true
  162. line.Locked = true
  163. line.CanCollide = false
  164. line.TopSurface = 0
  165. line.BottomSurface = 0
  166. line.Name = "BulletStreak"
  167. line.Size = Vector3.new(0.5,0.5,0.5)
  168. line.CanCollide = false
  169. line.BrickColor = BrickColor.new("Really black")
  170. line.Transparency = 0.55
  171. line.CFrame = CFrame.new((pos1z + enz)/2, pos1z)
  172. local muz = line:Clone()
  173. muz.Parent = bin
  174. muz.Anchored = false
  175. muz.Transparency = 0.75
  176. muz.CFrame = (haz.CFrame + Vector3.new(0,0.3,0)) + (haz.CFrame.lookVector * 2)
  177. local meshz = Instance.new("SpecialMesh", muz)
  178. meshz.MeshType = "Sphere"
  179. meshz.Scale = Vector3.new(0.7,0.7,1.45)
  180. muzw = Instance.new("Weld", muz)
  181. muzw.Part0 = haz
  182. muzw.Part1 = muz
  183. muzw.C0 = CFrame.new(0,0.3,-2.75)
  184. local mesh = Instance.new("BlockMesh", line)
  185. mesh.Scale = Vector3.new(0.12,0.12,(pos1z - enz).magnitude+0.3)
  186. game:service("Debris"):AddItem(line, (0.038*5))
  187. game:service("Debris"):AddItem(muz, 0.06)
  188. if hitz.Parent.className == "Model" then
  189. for _, hu in pairs(hitz.Parent:children()) do
  190. if hu.className == "Humanoid" then
  191. if AntiTK == true then
  192. if game:service("Players"):GetPlayerFromCharacter(hitz.Parent).Neutral == true or game:service("Players"):GetPlayerFromCharacter(hitz.Parent).TeamColor ~= game:service("Players").LocalPlayer.TeamColor then
  193. hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10
  194. if hitz.Name == "Head" then
  195. hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10/2
  196. end
  197. end
  198. elseif AntiTK == false then
  199. hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10
  200. if hitz.Name == "Head" then
  201. hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10/2
  202. end
  203. end
  204. end
  205.  
  206. end
  207. elseif hitz.Parent.className == "Hat" and hitz.Parent.Parent.className == "Model" then
  208. for _, hu in pairs(hitz.Parent.Parent:children()) do
  209. if hu.className == "Humanoid" then
  210. if AntiTK == true then
  211. if game:service("Players"):GetPlayerFromCharacter(hitz.Parent.Parent).Neutral == true or game:service("Players"):GetPlayerFromCharacter(hitz.Parent.Parent).TeamColor ~= game:service("Players").LocalPlayer.TeamColor then
  212. hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10
  213. hu.Health = hu.Health - (math.random(mindmg*10, maxdmg*10)/10)/2
  214. end
  215. elseif AntiTK == false then
  216. hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10
  217. hu.Health = hu.Health - (math.random(mindmg*10, maxdmg*10)/10)/2
  218. end
  219. end
  220. end
  221. hitz:BreakJoints()
  222. end
  223. for _ = 1, 5 do
  224. line.Transparency = line.Transparency + 0.08
  225. mesh.Scale = mesh.Scale + Vector3.new(-0.03,-0.03,0)
  226. wait(0.038)
  227. end
  228. end
  229.  
  230. function RecoilAnim()
  231. Joint1.C0 = CFrame.new(-0.2,0.525,-1.08) * CFrame.Angles(math.pi/1.85,0,0.5)
  232. Joint2.C0 = CFrame.new(1,0.525,-0.63) * CFrame.Angles(math.pi/1.85,0,-math.pi/12)
  233. Joint5.C0 = CFrame.new(0.2,1.35,0) * CFrame.Angles(0.12,0,-0.125)
  234. wait(0.08)
  235. Joint1.C0 = CFrame.new(-0.2,0.5,-1.2) * CFrame.Angles(math.pi/2,0,0.5)
  236. Joint2.C0 = CFrame.new(1,0.5,-0.75) * CFrame.Angles(math.pi/2,0,-math.pi/12)
  237. Joint5.C0 = CFrame.new(0.2,1.35,0) * CFrame.Angles(0,0,-0.125)
  238. end
  239.  
  240. function onButton1Down(mouse)
  241. if ReloadReady == true then
  242. Down.Value = math.random(0, 80000)
  243. local tehval = Down.Value
  244. while Down.Value == tehval do
  245. ReloadReady = false
  246. if CurrentAmmoClip.Value > 0 then
  247. for _ = 1, ShotsPerAmmo do
  248. coroutine.resume(coroutine.create(Shoot), mouse)
  249. end
  250. coroutine.resume(coroutine.create(RecoilAnim))
  251. coroutine.resume(coroutine.create(function()
  252. local thepitch = math.random(6, 7)/10
  253. wait()
  254. coroutine.resume(coroutine.create(PlaySound), "http://roblox.com/asset/?id=10209803", thepitch, 0.75)
  255. end))
  256. CurrentAmmoClip.Value = CurrentAmmoClip.Value - 1
  257. end
  258. wait(ShootSpeed)
  259. end
  260. ReloadReady = true
  261. end
  262. end
  263.  
  264. function onButton1Up()
  265. Down.Value = math.random(0, 80000)
  266. end
  267.  
  268. function Reload()
  269. if CurrentAmmo.Value > 0 then
  270. local amount = CurrentAmmoClip.Value + CurrentAmmo.Value
  271. if amount < AmmoPerClip then
  272. CurrentAmmoClip.Value = amount
  273. CurrentAmmo.Value = 0
  274. elseif amount >= AmmoPerClip then
  275. CurrentAmmoClip.Value = AmmoPerClip
  276. CurrentAmmo.Value = amount - AmmoPerClip
  277. end
  278. end
  279. end
  280.  
  281. local crouchingz = false
  282. local inscope = false
  283. function Scope(mouse)
  284. inscope = true
  285. game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = 0
  286. workspace.CurrentCamera.FieldOfView = 42
  287. end
  288.  
  289. function onKeyDown(key, mouse)
  290. if key ~= nil then
  291. key:lower()
  292. if key == "q" then
  293. bin.Name = "Deselect = Remove"
  294. bin.Unequipped:connect(function() wait() bin:remove() end)
  295. elseif key == "r" then
  296. if ReloadReady == true then
  297. coroutine.resume(coroutine.create(Reload))
  298. end
  299. elseif key == "c" then
  300. game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = crouchingwalkspeed
  301. Accuracy = CrouchingAccuracy
  302. CrouchAnim("Crouch")
  303. crouchingz = true
  304. if inscope == true then
  305. game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = 0
  306. end
  307. elseif key == "z" then
  308. if inscope == false then
  309. coroutine.resume(coroutine.create(Scope), mouse)
  310. else
  311. inscope = false
  312. workspace.CurrentCamera.FieldOfView = 70
  313. if crouchingz == true then
  314. game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = crouchingwalkspeed
  315. else
  316. game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = thecrouchwalkspeed
  317. end
  318. end
  319.  
  320. end
  321. end
  322. end
  323.  
  324. function onKeyUp(key)
  325. if key ~= nil then
  326. key:lower()
  327. if key == "c" then
  328. game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = thecrouchwalkspeed
  329. Accuracy = StandingAccuracy
  330. CrouchAnim("Stand")
  331. crouchingz = false
  332. if inscope == true then
  333. game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = 0
  334. end
  335. end
  336. end
  337. end
  338.  
  339. equiped = false
  340. function FaceTarget(mouse)
  341. local bg = Instance.new("BodyGyro")
  342. bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  343. bg.D = 100
  344. bg.Parent = Torsoz
  345. local pos1 = Torsoz.Position
  346. local pos2 = Vector3.new(mouse.Hit.x, pos1.y,mouse.Hit.z)
  347. bg.cframe = CFrame.new(pos1, pos2)
  348. equiped = true
  349. while equiped == true do
  350. pos1 = Torsoz.Position
  351. pos2 = Vector3.new(mouse.Hit.x, pos1.y,mouse.Hit.z)
  352. bg.cframe = CFrame.new(pos1, pos2)
  353. wait()
  354. end
  355. game:service("Debris"):AddItem(bg, 0)
  356. end
  357.  
  358. function Armz()
  359. LeftJoint.Part0 = nil
  360. RightJoint.Part0 = nil
  361. NeckJoint.Part0 = nil
  362. Joint1 = Instance.new("Motor", Torsoz)
  363. Joint2 = Instance.new("Motor", Joint1.Parent)
  364. Joint5 = Instance.new("Motor", Joint1.Parent)
  365. Joint1.Part0 = Joint1.Parent
  366. Joint2.Part0 = Joint1.Parent
  367. Joint5.Part0 = Joint1.Parent
  368. Joint1.Part1 = bin.Parent:findFirstChild("Left Arm")
  369. Joint2.Part1 = bin.Parent:findFirstChild("Right Arm")
  370. Joint5.Part1 = bin.Parent:findFirstChild("Head")
  371. Joint1.C0 = CFrame.new(-0.2,0.5,-1.2) * CFrame.Angles(math.pi/2,0,0.5)
  372. Joint2.C0 = CFrame.new(1,0.5,-0.75) * CFrame.Angles(math.pi/2,0,-math.pi/12)
  373. Joint5.C0 = CFrame.new(0.2,1.35,0) * CFrame.Angles(0,0,-0.125)
  374. end
  375.  
  376. local meshi = Instance.new("SpecialMesh")
  377. meshi.MeshType = "Brick"
  378. meshi.Scale = Vector3.new(1.02,10,1.02)
  379. local meshi2 = meshi:Clone()
  380. function CrouchAnim(which)
  381. if which == "Stand" then
  382. Joint3:remove()
  383. Joint4:remove()
  384. meshi.Parent = nil
  385. meshi2.Parent = nil
  386. RL.formFactor = "Symmetric"
  387. LL.formFactor = "Symmetric"
  388. RL.Size = Vector3.new(1,2,1)
  389. LL.Size = Vector3.new(1,2,1)
  390. LeftJoint2.Part0 = Torsoz
  391. RightJoint2.Part0 = Torsoz
  392. elseif which == "Crouch" then
  393. LeftJoint2.Part0 = nil
  394. RightJoint2.Part0 = nil
  395. meshi.Parent = RL
  396. meshi2.Parent = LL
  397. RL.formFactor = "Custom"
  398. LL.formFactor = "Custom"
  399. RL.Size = Vector3.new(1,0.2,1)
  400. LL.Size = Vector3.new(1,0.2,1)
  401. Joint3 = Instance.new("Motor", Torsoz)
  402. Joint4 = Instance.new("Motor", Joint3.Parent)
  403. Joint3.Part0 = Joint3.Parent
  404. Joint4.Part0 = Joint3.Parent
  405. Joint3.Part1 = bin.Parent:findFirstChild("Left Leg")
  406. Joint4.Part1 = bin.Parent:findFirstChild("Right Leg")
  407. Joint3.C0 = CFrame.new(-0.5,-0.8,0.75) * CFrame.Angles(-math.pi/2,0,0)
  408. Joint4.C0 = CFrame.new(0.5,-0.3,-1)
  409. end
  410. end
  411.  
  412.  
  413. bin.Equipped:connect(function(mouse)
  414. LeftJoint = Torsoz:findFirstChild("Left Shoulder")
  415. RightJoint = Torsoz:findFirstChild("Right Shoulder")
  416. LeftJoint2 = Torsoz:findFirstChild("Left Hip")
  417. RightJoint2 = Torsoz:findFirstChild("Right Hip")
  418. NeckJoint = Torsoz:findFirstChild("Neck")
  419. han.Parent = bin
  420. haz.Parent = bin
  421. gui.Parent = PlayGui
  422. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  423. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  424. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  425. mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
  426. mouse.KeyUp:connect(function(key) onKeyUp(key) end)
  427. wait(0.1)
  428. coroutine.resume(coroutine.create(Armz))
  429. coroutine.resume(coroutine.create(FaceTarget), mouse)
  430. if GunWeld ~= nil then
  431. GunWeld:remove()
  432. end
  433. GunWeld = Instance.new("Weld")
  434. GunWeld.Parent = bin
  435. GunWeld.Part0 = han
  436. GunWeld.Part1 = haz
  437. GunWeld.C0 = CFrame.new(0,0.25,-0.5) * CFrame.Angles(0,-0.2,0)
  438. han.CanCollide = false
  439. haz.CanCollide = true
  440. end)
  441. bin.Unequipped:connect(function()
  442. equiped = false
  443. gui.Parent = nil
  444. Joint1:remove()
  445. Joint2:remove()
  446. Joint5:remove()
  447. LeftJoint.Part0 = Torsoz
  448. RightJoint.Part0 = Torsoz
  449. NeckJoint.Part0 = Torsoz
  450. if LA ~= nil then
  451. LeftJoint.Part1 = LA
  452. end
  453. if RA ~= nil then
  454. RightJoint.Part1 = RA
  455. end
  456. for _, vv in pairs(Torsoz:children()) do
  457. if vv.className == "BodyGyro" then
  458. vv:remove()
  459. end
  460. end
  461. if GunWeld ~= nil then
  462. GunWeld:remove()
  463. end
  464. GunWeld = Instance.new("Weld")
  465. GunWeld.Parent = bin
  466. GunWeld.Part0 = han
  467. GunWeld.Part1 = haz
  468. han.CanCollide = true
  469. haz.CanCollide = false
  470. end)
Add Comment
Please, Sign In to add comment