BINO2002

Untitled

Jan 13th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.38 KB | None | 0 0
  1. --[[
  2. Tesla Cannon; fires a bolt of electricity bound to fry anyone or anything it hits.
  3. --]]
  4.  
  5.  
  6. if script == nil then return end
  7.  
  8.  
  9. Player = game:GetService("Players").LocalPlayer
  10. Char = Player.Character
  11. animate = Char:findFirstChild("Animate")
  12. if animate then
  13. animate:Destroy()
  14. end
  15.  
  16. Name = "TeslaGun"
  17. MC = BrickColor.new("Dark stone grey")
  18. DC = BrickColor.new("Black")
  19. GC = BrickColor.new("Black")
  20. MR = 0
  21. GR = 0
  22. WSPenalty = 5
  23. selected = false
  24. canDual = false
  25. dual = false
  26. Button1Down = false
  27. damage = 85
  28. canFire = true
  29. canFire2 = false
  30. readyTime = 0.12
  31. automatic = false
  32. burst = false
  33. burstCount = 0
  34. burstCountMax = 3
  35. canSilence = false
  36. silenced = false
  37. canZoom = true
  38. zoom = false
  39. switchToSingle = true
  40. switchToBurst = false
  41. switchToAutomatic = false
  42.  
  43.  
  44. ammoGui = Instance.new("ScreenGui")
  45. ammoGui.Name = Name
  46. local frame = Instance.new("Frame")
  47. frame.Name = "Frame"
  48. frame.Size = UDim2.new(0, 165, 0, 60)
  49. frame.Position = UDim2.new(0, 0, 1, -400)
  50. frame.BackgroundColor3 = Color3.new(1, 1, 1)
  51. frame.BorderColor3 = Color3.new(0, 0, 0)
  52. frame.Parent = ammoGui
  53. local label = Instance.new("TextLabel")
  54. label.Name = "Weapon"
  55. label.Text = "Weapon: " ..Name
  56. label.Size = UDim2.new(1, 0, 0, 20)
  57. label.Position = UDim2.new(0, 0, 0, 0)
  58. label.BackgroundColor3 = Color3.new(1, 0, 0)
  59. label.BorderColor3 = Color3.new(0, 0, 0)
  60. label.Parent = frame
  61. local label = Instance.new("TextLabel")
  62. label.Name = "MagazinePrefix"
  63. label.Text = " Cell:"
  64. label.TextXAlignment = "Left"
  65. label.Size = UDim2.new(1, 0, 0, 20)
  66. label.Position = UDim2.new(0, 0, 0, 20)
  67. label.BackgroundColor3 = Color3.new(1, 1, 1)
  68. label.BorderColor3 = Color3.new(0, 0, 0)
  69. label.Parent = frame
  70. local label = Instance.new("TextLabel")
  71. label.Name = "Magazine"
  72. label.Text = "0/0"
  73. label.TextXAlignment = "Right"
  74. label.Size = UDim2.new(1, 0, 0, 20)
  75. label.Position = UDim2.new(0, -10, 0, 20)
  76. label.BackgroundTransparency = 1
  77. label.BorderSizePixel = 0
  78. label.Parent = frame
  79. local label = Instance.new("TextLabel")
  80. label.Name = "AmmoPrefix"
  81. label.Text = " EC Pack:"
  82. label.TextXAlignment = "Left"
  83. label.Size = UDim2.new(1, 0, 0, 20)
  84. label.Position = UDim2.new(0, 0, 0, 40)
  85. label.BackgroundColor3 = Color3.new(1, 1, 1)
  86. label.BorderColor3 = Color3.new(0, 0, 0)
  87. label.Parent = frame
  88. local label = Instance.new("TextLabel")
  89. label.Name = "Ammo"
  90. label.Text = "0/0"
  91. label.TextXAlignment = "Right"
  92. label.Size = UDim2.new(1, 0, 0, 20)
  93. label.Position = UDim2.new(0, -10, 0, 40)
  94. label.BackgroundTransparency = 1
  95. label.BorderSizePixel = 0
  96. label.Parent = frame
  97.  
  98.  
  99. function updateGui()
  100. if selected == false then return end
  101. if Player:FindFirstChild("PlayerGui") == nil then Instance.new("PlayerGui").Parent = Player end
  102. if Player.PlayerGui:FindFirstChild(Name) == nil then
  103. ammoGui:Clone().Parent = Player.PlayerGui
  104. end
  105. Player.PlayerGui[Name].Frame.Magazine.Text = tostring(magazine.Value).. "/" ..tostring(magazineMax.Value)
  106. Player.PlayerGui[Name].Frame.Ammo.Text = tostring(ammo.Value).. "/" ..tostring(ammoMax.Value)
  107. end
  108.  
  109.  
  110. function makeParts(format)
  111. local model = Instance.new("Model")
  112. model.Name = Name
  113. local pm = Instance.new("Part")
  114. pm.Name = "Handle"
  115. pm.formFactor = "Symmetric"
  116. pm.Size = Vector3.new(1, 1, 1)
  117. pm.BrickColor = MC
  118. pm.Transparency = 1
  119. pm.CanCollide = false
  120. pm.Locked = true
  121. pm.TopSurface = 0
  122. pm.BottomSurface = 0
  123. pm.Parent = model
  124. local m = Instance.new("BlockMesh")
  125. m.Scale = Vector3.new(0.3, 1.1, 0.41)
  126. m.Offset = Vector3.new(0, -0.14, 0.07)
  127. m.Parent = pm
  128. if format ~= nil then
  129. local w = Instance.new("Weld")
  130. w.Part0 = pm
  131. if format == "RightHand" then
  132. w.Part1 = Player.Character:FindFirstChild("Right Arm")
  133. w.C0 = CFrame.new(0, 1.5, 0.75)
  134. w.C1 = CFrame.new()
  135. elseif format == "RightHolster" then
  136. w.Part1 = Player.Character:FindFirstChild("Torso")
  137. w.C0 = CFrame.new(-0.65, 1, 0) * CFrame.fromEulerAnglesXYZ(math.rad(-40), math.rad(90), 0)
  138. w.C1 = CFrame.new()
  139. model.Name = Name.. " (Holstered)"
  140. end
  141. w.Parent = pm
  142. model.Parent = Player.Character
  143. end
  144. --[[
  145. sniper1 http://www.roblox.com/asset/?id=1868836
  146. equip http://www.roblox.com/asset/?id=13510737
  147. fire1 http://www.roblox.com/asset/?id=2760979
  148. fire2 http://www.roblox.com/asset/?id=13510352
  149. fire3 http://www.roblox.com/asset/?id=2692806
  150. fire4 http://www.roblox.com/asset/?id=2691586
  151. fire5 http://www.roblox.com/asset/?id=2920959
  152. fire6 http://www.roblox.com/asset/?id=2697431
  153. fire7 http://www.roblox.com/asset/?id=2920959
  154. reload1 http://www.roblox.com/asset/?id=2691591
  155. reload2 http://www.roblox.com/asset/?id=2697432
  156. reload3 http://www.roblox.com/asset/?id=2920960
  157. reload4 http://www.roblox.com/asset/?id=2761842
  158. shotgun1 http://www.roblox.com/asset/?id=2697294
  159. --]]
  160. local s = Instance.new("Sound")
  161. s.Name = "Fire"
  162. s.SoundId = "http://roblox.com/asset/?id=10209268"
  163. s.Volume = 1
  164. s.Pitch = 1
  165. s.Looped = false
  166. s.Parent = pm
  167. local s = Instance.new("Sound")
  168. s.Name = "Lock"
  169. s.SoundId = "http://www.roblox.com/asset/?id=2697295"
  170. s.Volume = 1
  171. s.Pitch = 3
  172. s.Looped = false
  173. s.Parent = pm
  174. local s = Instance.new("Sound")
  175. s.Name = "Reload"
  176. s.SoundId = "http://www.roblox.com/asset/?id=2761842"
  177. s.Volume = 1
  178. s.Pitch = 1.1
  179. s.Looped = false
  180. s.Parent = pm
  181. local s = Instance.new("Sound")
  182. s.Name = "Empty"
  183. s.SoundId = "http://www.roblox.com/asset/?id=2697295"
  184. s.Volume = 1
  185. s.Pitch = 5
  186. s.Looped = false
  187. s.Parent = pm
  188. local s = Instance.new("Sound")
  189. s.Name = "Switch"
  190. s.SoundId = "http://www.roblox.com/asset/?id=2697295"
  191. s.Volume = 1
  192. s.Pitch = 10
  193. s.Looped = false
  194. s.Parent = pm
  195. local s = Instance.new("Sound")
  196. s.Name = "Equip"
  197. s.SoundId = "http://www.roblox.com/asset/?id=10209881"
  198. s.Volume = 1
  199. s.Pitch = 0.6
  200. s.Looped = false
  201. s.Parent = pm
  202. local p = Instance.new("Part")
  203. p.Name = "ShellOut"
  204. p.formFactor = "Symmetric"
  205. p.Size = Vector3.new(1, 1, 1)
  206. p.Transparency = 1
  207. p.Locked = true
  208. p.CanCollide = false
  209. p.TopSurface = 0
  210. p.BottomSurface = 0
  211. p.Parent = model
  212. local w = Instance.new("Weld")
  213. w.Part0 = p
  214. w.Part1 = pm
  215. w.C0 = CFrame.new(0, 0, 1) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  216. w.C1 = CFrame.new()
  217. w.Parent = p
  218. local p = Instance.new("Part")
  219. p.Name = "Grip"
  220. p.formFactor = "Symmetric"
  221. p.Size = Vector3.new(1, 1, 1)
  222. p.BrickColor = MC
  223. p.CanCollide = false
  224. p.Locked = true
  225. p.TopSurface = 0
  226. p.BottomSurface = 0
  227. p.Parent = model
  228. local m = Instance.new("SpecialMesh")
  229. m.MeshType = "Brick"
  230. m.Scale = Vector3.new(0.29, 0.35, 0.7)
  231. m.Parent = p
  232. local w = Instance.new("Weld")
  233. w.Part0 = p
  234. w.Part1 = pm
  235. w.C0 = CFrame.new(0, -0.7, -0.5)
  236. w.C1 = CFrame.new()
  237. w.Parent = p
  238. local p = Instance.new("Part")
  239. p.Name = "Trigger"
  240. p.formFactor = "Symmetric"
  241. p.Size = Vector3.new(1, 1, 1)
  242. p.BrickColor = BrickColor.new("Bright red")
  243. p.Locked = true
  244. p.CanCollide = false
  245. p.TopSurface = 0
  246. p.BottomSurface = 0
  247. p.Parent = model
  248. local m = Instance.new("SpecialMesh")
  249. m.MeshType = "Brick"
  250. m.Scale = Vector3.new(0.1, 0.05, 0.15)
  251. m.Parent = p
  252. local w = Instance.new("Weld")
  253. w.Part0 = p
  254. w.Part1 = pm
  255. w.C0 = CFrame.new(0, -0.5, -0.28)
  256. w.C1 = CFrame.new()
  257. w.Parent = p
  258. local p = Instance.new("Part")
  259. p.Name = "Bolt"
  260. p.formFactor = "Symmetric"
  261. p.Size = Vector3.new(1, 1, 1)
  262. p.BrickColor = BrickColor.new("Bright blue")
  263. p.Reflectance = 0.35
  264. p.Transparency = 1
  265. p.CanCollide = false
  266. p.Locked = true
  267. p.TopSurface = 0
  268. p.BottomSurface = 0
  269. p.Parent = model
  270. local m = Instance.new("SpecialMesh")
  271. m.MeshType = "Sphere"
  272. m.Scale = Vector3.new(2, 2, 2)
  273. m.Parent = p
  274. local w = Instance.new("Weld")
  275. w.Part0 = p
  276. w.Part1 = pm
  277. w.C0 = CFrame.new(0, 1, 0)
  278. w.C1 = CFrame.new()
  279. w.Parent = p
  280. local p = Instance.new("Part")
  281. p.Name = "Magazine"
  282. p.formFactor = "Symmetric"
  283. p.Size = Vector3.new(1, 1, 1)
  284. p.BrickColor = BrickColor.new("White")
  285. p.CanCollide = false
  286. p.Locked = true
  287. p.TopSurface = 0
  288. p.BottomSurface = 0
  289. p.Parent = model
  290. local m = Instance.new("CylinderMesh")
  291. m.Scale = Vector3.new(0.4, 0.8, 0.4)
  292. m.Parent = p
  293. local w = Instance.new("Weld")
  294. w.Part0 = p
  295. w.Part1 = pm
  296. w.C0 = CFrame.new(0, 0.11, -0.2) * CFrame.fromEulerAnglesXYZ(math.rad(-20), 0, 0)
  297. w.C1 = CFrame.new()
  298. w.Parent = p
  299. local p = Instance.new("Part")
  300. p.Name = "EndBack"
  301. p.formFactor = "Symmetric"
  302. p.Size = Vector3.new(1, 1, 1)
  303. p.BrickColor = GC
  304. p.CanCollide = false
  305. p.Locked = true
  306. p.TopSurface = 0
  307. p.BottomSurface = 0
  308. p.Parent = model
  309. local m = Instance.new("CylinderMesh")
  310. m.Scale = Vector3.new(0.65, 0.8, 0.64)
  311. m.Parent = p
  312. local w = Instance.new("Weld")
  313. w.Part0 = p
  314. w.Part1 = pm
  315. w.C0 = CFrame.new(0, 3.2, 0) * CFrame.fromEulerAnglesXYZ(math.rad(180), 0, 0)
  316. w.C1 = CFrame.new()
  317. w.Parent = p
  318. local p = Instance.new("Part")
  319. p.Name = "Center"
  320. p.formFactor = "Symmetric"
  321. p.Size = Vector3.new(1, 1, 1)
  322. p.BrickColor = MC
  323. p.CanCollide = false
  324. p.Locked = true
  325. p.TopSurface = 0
  326. p.BottomSurface = 0
  327. p.Parent = model
  328. local m = Instance.new("CylinderMesh")
  329. m.Scale = Vector3.new(0.5, 4, 0.5)
  330. m.Parent = p
  331. local w = Instance.new("Weld")
  332. w.Part0 = p
  333. w.Part1 = pm
  334. w.C0 = CFrame.new(0, -1.2, 0)
  335. w.C1 = CFrame.new()
  336. w.Parent = p
  337. local p = Instance.new("Part")
  338. p.Name = "Pipe"
  339. p.formFactor = "Symmetric"
  340. p.Size = Vector3.new(1, 1, 1)
  341. p.BrickColor = DC
  342. p.CanCollide = false
  343. p.Locked = true
  344. p.TopSurface = 0
  345. p.BottomSurface = 0
  346. p.Parent = model
  347. local m = Instance.new("CylinderMesh")
  348. m.Scale = Vector3.new(0.1, 4, 0.1)
  349. m.Parent = p
  350. local w = Instance.new("Weld")
  351. w.Part0 = p
  352. w.Part1 = pm
  353. w.C0 = CFrame.new(0.15, -1.2, 0.15)
  354. w.C1 = CFrame.new()
  355. w.Parent = p
  356. local p = Instance.new("Part")
  357. p.Name = "Pipe"
  358. p.formFactor = "Symmetric"
  359. p.Size = Vector3.new(1, 1, 1)
  360. p.BrickColor = DC
  361. p.CanCollide = false
  362. p.Locked = true
  363. p.TopSurface = 0
  364. p.BottomSurface = 0
  365. p.Parent = model
  366. local m = Instance.new("CylinderMesh")
  367. m.Scale = Vector3.new(0.1, 4, 0.1)
  368. m.Parent = p
  369. local w = Instance.new("Weld")
  370. w.Part0 = p
  371. w.Part1 = pm
  372. w.C0 = CFrame.new(-0.15, -1.2, 0.15)
  373. w.C1 = CFrame.new()
  374. w.Parent = p
  375. local p = Instance.new("Part")
  376. p.Name = "Pipe"
  377. p.formFactor = "Symmetric"
  378. p.Size = Vector3.new(1, 1, 1)
  379. p.BrickColor = DC
  380. p.CanCollide = false
  381. p.Locked = true
  382. p.TopSurface = 0
  383. p.BottomSurface = 0
  384. p.Parent = model
  385. local m = Instance.new("CylinderMesh")
  386. m.Scale = Vector3.new(0.1, 4, 0.1)
  387. m.Parent = p
  388. local w = Instance.new("Weld")
  389. w.Part0 = p
  390. w.Part1 = pm
  391. w.C0 = CFrame.new(0.15, -1.2, -0.15)
  392. w.C1 = CFrame.new()
  393. w.Parent = p
  394. local p = Instance.new("Part")
  395. p.Name = "Pipe"
  396. p.formFactor = "Symmetric"
  397. p.Size = Vector3.new(1, 1, 1)
  398. p.BrickColor = DC
  399. p.CanCollide = false
  400. p.Locked = true
  401. p.TopSurface = 0
  402. p.BottomSurface = 0
  403. p.Parent = model
  404. local m = Instance.new("CylinderMesh")
  405. m.Scale = Vector3.new(0.1, 4, 0.1)
  406. m.Parent = p
  407. local w = Instance.new("Weld")
  408. w.Part0 = p
  409. w.Part1 = pm
  410. w.C0 = CFrame.new(-0.15, -1.2, -0.15)
  411. w.C1 = CFrame.new()
  412. w.Parent = p
  413. local p = Instance.new("Part")
  414. p.Name = "Stripe"
  415. p.formFactor = "Symmetric"
  416. p.Size = Vector3.new(1, 1, 1)
  417. p.BrickColor = BrickColor.new("Cyan")
  418. p.CanCollide = false
  419. p.Locked = true
  420. p.TopSurface = 0
  421. p.BottomSurface = 0
  422. p.Parent = model
  423. local m = Instance.new("CylinderMesh")
  424. m.Scale = Vector3.new(0.51, 0.4, 0.51)
  425. m.Parent = p
  426. local w = Instance.new("Weld")
  427. w.Part0 = p
  428. w.Part1 = pm
  429. w.C0 = CFrame.new(0, -1, 0)
  430. w.C1 = CFrame.new()
  431. w.Parent = p
  432. local p = Instance.new("Part")
  433. p.Name = "Muzzle"
  434. p.formFactor = "Symmetric"
  435. p.Size = Vector3.new(1, 1, 1)
  436. p.BrickColor = DC
  437. p.Locked = true
  438. p.TopSurface = 0
  439. p.BottomSurface = 0
  440. p.Parent = model
  441. local m = Instance.new("CylinderMesh")
  442. m.Scale = Vector3.new(0.64, 0.8, 0.64)
  443. m.Parent = p
  444. local w = Instance.new("Weld")
  445. w.Part0 = p
  446. w.Part1 = pm
  447. w.C0 = CFrame.new(0, 1, 0)
  448. w.C1 = CFrame.new()
  449. w.Parent = p
  450. local s = Instance.new("Smoke")
  451. s.Enabled = false
  452. s.Name = "Smoke"
  453. s.RiseVelocity = 5
  454. s.Opacity = 0.2
  455. s.Color = Color3.new(75 / 225, 75 / 225, 75 / 225)
  456. s.Size = 1
  457. s.Parent = p
  458. local f = Instance.new("Fire")
  459. f.Enabled = false
  460. f.Name = "Fire"
  461. f.Color = Color3.new(0 / 0, 0 / 0, 0 / 0)
  462. f.SecondaryColor = Color3.new(0 / 0, 0 / 0, 0 / 0)
  463. f.Heat = -35
  464. f.Size = 1
  465. f.Parent = p
  466. local p = Instance.new("Part")
  467. p.Name = "Silencer"
  468. p.formFactor = "Symmetric"
  469. p.Size = Vector3.new(1, 1, 1)
  470. p.BrickColor = BrickColor.new("Black")
  471. p.CanCollide = false
  472. p.Transparency = 1
  473. p.Locked = true
  474. p.TopSurface = 0
  475. p.BottomSurface = 0
  476. p.Parent = model
  477. local m = Instance.new("CylinderMesh")
  478. m.Scale = Vector3.new(0.25, 0.8, 0.25)
  479. m.Parent = p
  480. local w = Instance.new("Weld")
  481. w.Part0 = p
  482. w.Part1 = pm
  483. w.C0 = CFrame.new(0, 2.5, -0.04)
  484. w.C1 = CFrame.new()
  485. w.Parent = p
  486. local p = Instance.new("Part")
  487. p.Name = "Scope Base"
  488. p.formFactor = "Symmetric"
  489. p.Size = Vector3.new(1, 1, 1)
  490. p.BrickColor = MC
  491. p.Locked = true
  492. p.TopSurface = 0
  493. p.BottomSurface = 0
  494. p.Parent = model
  495. local m = Instance.new("BlockMesh")
  496. m.Scale = Vector3.new(0.1, 0.32, 0.4)
  497. m.Parent = p
  498. local w = Instance.new("Weld")
  499. w.Part0 = p
  500. w.Part1 = pm
  501. w.C0 = CFrame.new(0.1, 0, 0.36)
  502. w.C1 = CFrame.new()
  503. w.Parent = p
  504. local p = Instance.new("Part")
  505. p.Name = "Scope End 1" --End = Back
  506. p.formFactor = "Symmetric"
  507. p.Size = Vector3.new(1, 1, 1)
  508. p.BrickColor = MC
  509. p.Locked = true
  510. p.TopSurface = 0
  511. p.BottomSurface = 0
  512. p.Parent = model
  513. local m = Instance.new("BlockMesh")
  514. m.Scale = Vector3.new(0.36, 0.4, 0.26)
  515. m.Parent = p
  516. local w = Instance.new("Weld")
  517. w.Part0 = p
  518. w.Part1 = pm
  519. w.C0 = CFrame.new(0, -0.4, 0.475)
  520. w.C1 = CFrame.new()
  521. w.Parent = p
  522. local p = Instance.new("Part")
  523. p.Name = "Scope End W" --End = Back
  524. p.formFactor = "Symmetric"
  525. p.Size = Vector3.new(1, 1, 1)
  526. p.BrickColor = BrickColor.new("Lime green")
  527. p.Reflectance = 0.5
  528. p.Locked = true
  529. p.TopSurface = 0
  530. p.BottomSurface = 0
  531. p.Parent = model
  532. local m = Instance.new("BlockMesh")
  533. m.Scale = Vector3.new(0.3, 0.4, 0.2)
  534. m.Parent = p
  535. local w = Instance.new("Weld")
  536. w.Part0 = p
  537. w.Part1 = pm
  538. w.C0 = CFrame.new(0, -0.402, 0.475)
  539. w.C1 = CFrame.new()
  540. w.Parent = p
  541. local p = Instance.new("Part")
  542. p.Name = "Scope Front W"
  543. p.formFactor = "Symmetric"
  544. p.Size = Vector3.new(1, 1, 1)
  545. p.BrickColor = BrickColor.new("Lime green")
  546. p.Reflectance = 0.5
  547. p.Locked = true
  548. p.TopSurface = 0
  549. p.BottomSurface = 0
  550. p.Parent = model
  551. local m = Instance.new("BlockMesh")
  552. m.Scale = Vector3.new(0.3, 0.4, 0.2)
  553. m.Parent = p
  554. local w = Instance.new("Weld")
  555. w.Part0 = p
  556. w.Part1 = pm
  557. w.C0 = CFrame.new(0, 0.502, 0.475)
  558. w.C1 = CFrame.new()
  559. w.Parent = p
  560. local p = Instance.new("Part")
  561. p.Name = "Scope Center 1"
  562. p.formFactor = "Symmetric"
  563. p.Size = Vector3.new(1, 1, 1)
  564. p.BrickColor = MC
  565. p.Locked = true
  566. p.TopSurface = 0
  567. p.BottomSurface = 0
  568. p.Parent = model
  569. local m = Instance.new("BlockMesh")
  570. m.Scale = Vector3.new(0.3, 0.7, 0.22)
  571. m.Parent = p
  572. local w = Instance.new("Weld")
  573. w.Part0 = p
  574. w.Part1 = pm
  575. w.C0 = CFrame.new(0, 0, 0.475)
  576. w.C1 = CFrame.new()
  577. w.Parent = p
  578. local p = Instance.new("Part")
  579. p.Name = "Scope Front 1"
  580. p.formFactor = "Symmetric"
  581. p.Size = Vector3.new(1, 1, 1)
  582. p.BrickColor = MC
  583. p.Locked = true
  584. p.TopSurface = 0
  585. p.BottomSurface = 0
  586. p.Parent = model
  587. local m = Instance.new("BlockMesh")
  588. m.Scale = Vector3.new(0.36, 0.4, 0.26)
  589. m.Parent = p
  590. local w = Instance.new("Weld")
  591. w.Part0 = p
  592. w.Part1 = pm
  593. w.C0 = CFrame.new(0, 0.5, 0.475)
  594. w.C1 = CFrame.new()
  595. w.Parent = p
  596. return model
  597. end
  598.  
  599.  
  600. function removeParts(format)
  601. if format == "RightHand" then
  602. pcall(function() Player.Character[Name]:Remove() end)
  603. elseif format == "LeftHand" then
  604. pcall(function() Player.Character[Name.. " (Left)"]:Remove() end)
  605. elseif format == "RightHolster" then
  606. pcall(function() Player.Character[Name.. " (Holstered)"]:Remove() end)
  607. elseif format == "LeftHolster" then
  608. pcall(function() Player.Character[Name.. " (Holstered, Left)"]:Remove() end)
  609. end
  610. end
  611.  
  612.  
  613. function SetAngle(Joint, Angle, Character)
  614. if Character == nil then return false end
  615. local Joints = {
  616. Character.Torso:FindFirstChild("Right Shoulder 2"),
  617. Character.Torso:FindFirstChild("Left Shoulder 2"),
  618. Character.Torso:FindFirstChild("Right Hip 2"),
  619. Character.Torso:FindFirstChild("Left Hip 2")
  620. }
  621. if Joints[Joint] == nil then return false end
  622. if Joint == 1 or Joint == 3 then
  623. Joints[Joint].DesiredAngle = Angle
  624. end
  625. if Joint == 2 or Joint == 4 then
  626. Joints[Joint].DesiredAngle = -Angle
  627. end
  628. end
  629.  
  630.  
  631. function ForceAngle(Joint, Angle, Character)
  632. if Character == nil then return false end
  633. local Joints = {
  634. Character.Torso:FindFirstChild("Right Shoulder 2"),
  635. Character.Torso:FindFirstChild("Left Shoulder 2"),
  636. Character.Torso:FindFirstChild("Right Hip 2"),
  637. Character.Torso:FindFirstChild("Left Hip 2")
  638. }
  639. if Joints[Joint] == nil then return false end
  640. if Joint == 1 or Joint == 3 then
  641. Joints[Joint].DesiredAngle = Angle
  642. Joints[Joint].CurrentAngle = Angle
  643. end
  644. if Joint == 2 or Joint == 4 then
  645. Joints[Joint].DesiredAngle = -Angle
  646. Joints[Joint].CurrentAngle = -Angle
  647. end
  648. end
  649.  
  650.  
  651. function SetSpeed(Joint, Speed, Character)
  652. if Character == nil then return false end
  653. local Joints = {
  654. Character.Torso:FindFirstChild("Right Shoulder 2"),
  655. Character.Torso:FindFirstChild("Left Shoulder 2"),
  656. Character.Torso:FindFirstChild("Right Hip 2"),
  657. Character.Torso:FindFirstChild("Left Hip 2")
  658. }
  659. if Joints[Joint] == nil then return false end
  660. Joints[Joint].MaxVelocity = Speed
  661. end
  662.  
  663.  
  664. function DisableLimb(Limb, Character)
  665. if Character == nil then return false end
  666. if Character:FindFirstChild("Torso") == nil then return false end
  667. local Joints = {
  668. Character.Torso:FindFirstChild("Right Shoulder"),
  669. Character.Torso:FindFirstChild("Left Shoulder"),
  670. Character.Torso:FindFirstChild("Right Hip"),
  671. Character.Torso:FindFirstChild("Left Hip")
  672. }
  673. local Limbs = {
  674. Character:FindFirstChild("Right Arm"),
  675. Character:FindFirstChild("Left Arm"),
  676. Character:FindFirstChild("Right Leg"),
  677. Character:FindFirstChild("Left Leg")
  678. }
  679. if Joints[Limb] == nil then return false end
  680. if Limbs[Limb] == nil then return false end
  681. local Joint = Instance.new("Motor")
  682. Joint.Parent = Character.Torso
  683. Joint.Part0 = Character.Torso
  684. Joint.Part1 = Limbs[Limb]
  685. if Limb == 1 then
  686. Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  687. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  688. Joint.Name = "Right Shoulder 2"
  689. elseif Limb == 2 then
  690. Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  691. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  692. Joint.Name = "Left Shoulder 2"
  693. elseif Limb == 3 then
  694. Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  695. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  696. Joint.Name = "Right Hip 2"
  697. elseif Limb == 4 then
  698. Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  699. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  700. Joint.Name = "Left Hip 2"
  701. end
  702. Joint.MaxVelocity = Joints[Limb].MaxVelocity
  703. Joint.CurrentAngle = Joints[Limb].CurrentAngle
  704. Joint.DesiredAngle = Joints[Limb].DesiredAngle
  705. Joints[Limb]:Remove()
  706. end
  707.  
  708.  
  709. function ResetLimbCFrame(Limb, Character)
  710. if Character == nil then return false end
  711. if Character.Parent == nil then return false end
  712. if Character:FindFirstChild("Torso") == nil then return false end
  713. local Joints = {
  714. Character.Torso:FindFirstChild("Right Shoulder 2"),
  715. Character.Torso:FindFirstChild("Left Shoulder 2"),
  716. Character.Torso:FindFirstChild("Right Hip 2"),
  717. Character.Torso:FindFirstChild("Left Hip 2")
  718. }
  719. local Limbs = {
  720. Character:FindFirstChild("Right Arm"),
  721. Character:FindFirstChild("Left Arm"),
  722. Character:FindFirstChild("Right Leg"),
  723. Character:FindFirstChild("Left Leg")
  724. }
  725. if Joints[Limb] == nil then return false end
  726. if Limbs[Limb] == nil then return false end
  727. if Limb == 1 then
  728. Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  729. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  730. elseif Limb == 2 then
  731. Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  732. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  733. elseif Limb == 3 then
  734. Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  735. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  736. elseif Limb == 4 then
  737. Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  738. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  739. end
  740. end
  741.  
  742.  
  743. function EnableLimb(Limb, Character)
  744. if Character == nil then return false end
  745. if Character:FindFirstChild("Torso") == nil then return false end
  746. local Joints = {
  747. Character.Torso:FindFirstChild("Right Shoulder 2"),
  748. Character.Torso:FindFirstChild("Left Shoulder 2"),
  749. Character.Torso:FindFirstChild("Right Hip 2"),
  750. Character.Torso:FindFirstChild("Left Hip 2")
  751. }
  752. local Limbs = {
  753. Character:FindFirstChild("Right Arm"),
  754. Character:FindFirstChild("Left Arm"),
  755. Character:FindFirstChild("Right Leg"),
  756. Character:FindFirstChild("Left Leg")
  757. }
  758. if Joints[Limb] == nil then return false end
  759. if Limbs[Limb] == nil then return false end
  760. if Limb == 1 then
  761. Joints[Limb].Name = "Right Shoulder"
  762. elseif Limb == 2 then
  763. Joints[Limb].Name = "Left Shoulder"
  764. elseif Limb == 3 then
  765. Joints[Limb].Name = "Right Hip"
  766. elseif Limb == 4 then
  767. Joints[Limb].Name = "Left Hip"
  768. end
  769. Animate = Character:FindFirstChild("Animate")
  770. if Animate == nil then return false end
  771. Animate = Animate:Clone()
  772. Character.Animate:Remove()
  773. Animate.Parent = Character
  774. end
  775.  
  776.  
  777. function playAnimation(format, mouse)
  778. if format == "equip" then
  779. Player.Character.Humanoid.WalkSpeed = WSPenalty
  780. Player.Character[Name.. " (Holstered)"].Handle.Weld:Remove()
  781. local w = Instance.new("Weld")
  782. w.Part0 = Player.Character[Name.. " (Holstered)"].Handle
  783. w.Part1 = Player.Character:FindFirstChild("Right Arm")
  784. w.C0 = CFrame.new(0, 1.2, 0.7)
  785. w.C1 = CFrame.new()
  786. w.Parent = Player.Character[Name.. " (Holstered)"].Handle
  787. for i = 0.01, 1, 0.1 do
  788. if Player.Character:FindFirstChild("Torso") ~= nil then
  789. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  790. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new()
  791. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new((-0.5 * i) + (1.5 * (1 - i)), 1.2 * i, 0.8 * i) * CFrame.fromEulerAnglesXYZ(math.rad(300 + ((1 - i) * 50)), math.rad(10), math.rad(-90) * i)
  792. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new()
  793. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new((-0.9 * i) + (-1.5 * (1 - i)), -0.35 * i, 0.51 * i) * CFrame.fromEulerAnglesXYZ(math.rad(-90 * i), math.rad(-5 * i), 0)
  794. wait()
  795. else return false end
  796. else return false end
  797. end
  798. return playAnimation("hold")
  799. end
  800. if format == "unequip" then
  801. Player.Character.Humanoid.WalkSpeed = 16
  802. for i = 1, 0.01, -0.1 do
  803. if Player.Character:FindFirstChild("Torso") ~= nil then
  804. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  805. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new()
  806. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new((-0.5 * i) + (1.5 * (1 - i)), 1.2 * i, 0.8 * i) * CFrame.fromEulerAnglesXYZ(math.rad(300 + ((1 - i) * 50)), math.rad(10), math.rad(-90) * i)
  807. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new()
  808. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new((-0.9 * i) + (-1.5 * (1 - i)), -0.35 * i, 0.51 * i) * CFrame.fromEulerAnglesXYZ(math.rad(-90 * i), math.rad(-5 * i), 0)
  809. wait()
  810. else return false end
  811. else return false end
  812. end
  813. return true
  814. end
  815. if format == "hold" then
  816. if Player.Character:FindFirstChild("Torso") ~= nil then
  817. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  818. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new()
  819. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(-0.5, 1.2, 0.8) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(10), math.rad(-90))
  820. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new()
  821. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(-0.9, -0.35, 0.51) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0)
  822. else return false end
  823. else return false end
  824. end
  825. if format == "reload" then
  826. for i = 0, 25, 5 do
  827. if Player.Character:FindFirstChild("Torso") ~= nil then
  828. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  829. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new()
  830. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(-0.9, -0.35, 0.51) * CFrame.fromEulerAnglesXYZ(math.rad(-90 + i), math.rad(-5), 0)
  831. wait()
  832. else return false end
  833. else return false end
  834. end
  835. Player.Character[Name].Handle.Reload:Play()
  836. Player.Character[Name].Magazine.Transparency = 1
  837. magazineDrop = Player.Character[Name].Magazine:Clone()
  838. magazineDrop.Transparency = 0
  839. magazineDrop.CanCollide = true
  840. magazineDrop.Parent = game.Workspace
  841. coroutine.resume(coroutine.create(function(part) wait(4.5) for i = 0, 1, 0.1 do part.Transparency = i wait() end part:Remove() end), magazineDrop)
  842. delay(0.1, function() magazineDrop.CanCollide = true end)
  843. for i = 0, 25, 5 do
  844. if Player.Character:FindFirstChild("Torso") ~= nil then
  845. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  846. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new()
  847. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(-0.5 + (i / 60), 1.2 - (i / 20), 0.8 + (i / 35)) * CFrame.fromEulerAnglesXYZ(math.rad(300 - i), math.rad(10 + -i * 3.5), math.rad(-90))
  848. wait()
  849. else return false end
  850. else return false end
  851. end
  852. magazineNew = Player.Character[Name].Magazine:Clone()
  853. magazineNew.Name = "New Magazine"
  854. magazineNew.Transparency = 0
  855. magazineNew.Parent = Player.Character[Name]
  856. local w = Instance.new("Weld")
  857. w.Part0 = magazineNew
  858. w.Part1 = Player.Character:FindFirstChild("Left Arm")
  859. w.C0 = CFrame.new(0, 1.1, 0)
  860. w.C1 = CFrame.new() * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  861. w.Parent = magazineNew
  862. wait(0.2)
  863. for i = 25, 0, -5 do
  864. if Player.Character:FindFirstChild("Torso") ~= nil then
  865. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  866. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new()
  867. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(-0.5 + ((i + 10) / 60), 1.2 - ((i + 10) / 20), 0.8 + (i / 35)) * CFrame.fromEulerAnglesXYZ(math.rad(300 - (i - 10)), math.rad(10 + -i * 3.5), math.rad(-90))
  868. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new()
  869. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(-1 + ((25 - i) / 30), 0.5, 0.6 + ((25 - i) / 25)) * CFrame.fromEulerAnglesXYZ(math.rad(-90 + i), math.rad(-5), math.rad((25 * 2) - (i * 2)))
  870. wait()
  871. else return false end
  872. else return false end
  873. end
  874. Player.Character[Name].Magazine.Transparency = 0
  875. Player.Character[Name]["New Magazine"]:Remove()
  876. wait(0.1)
  877. if Player.Character:FindFirstChild("Torso") ~= nil then
  878. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  879. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new()
  880. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(-0.5, 1.2, 0.8) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(10), math.rad(-90))
  881. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new()
  882. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(-0.9, -0.35, 0.51) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-5), 0)
  883. else return false end
  884. else return false end
  885. wait(0.7)
  886. Player.Character[Name].Handle.Reload:Stop()
  887. end
  888. if format == "fire" then
  889. Player.Character[Name].Bolt.Transparency = 0.8
  890. if Player.Character[Name]:FindFirstChild("Handle") ~= nil then
  891. if silenced then
  892. Player.Character[Name].Handle.Fire.Volume = math.random(3, 8) / 10
  893. Player.Character[Name].Handle.Fire.Pitch = math.random(20, 25) / 10
  894. Player.Character[Name].Handle.Fire:Play()
  895. CamShake(100, 5000)
  896. else
  897. Player.Character[Name].Handle.Fire.Volume = math.random(9, 10) / 10
  898. Player.Character[Name].Handle.Fire.Pitch = 1
  899. Player.Character[Name].Handle.Fire:Play()
  900. --Player.Character[Name].Handle.Fire2:Play()
  901. CamShake(10, 5000)
  902. end
  903. else return false end
  904. if Player.Character[Name]:FindFirstChild("Muzzle") ~= nil then
  905. coroutine.resume(coroutine.create(function() Player.Character[Name].Muzzle.Smoke.Enabled = true Player.Character[Name].Muzzle.Fire.Enabled = true wait(0.8) Player.Character[Name].Muzzle.Smoke.Enabled = false Player.Character[Name].Muzzle.Fire.Enabled = false end))
  906. else return false end
  907. for i = 0, 10, 5 do
  908. if Player.Character:FindFirstChild("Torso") ~= nil then
  909. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  910. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new()
  911. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(-0.5, 1.2, 0.8) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(10 + i), math.rad(-90))
  912. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new()
  913. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(-0.9, -0.35, 0.51) * CFrame.fromEulerAnglesXYZ(math.rad(-90 - i), math.rad(-5), 0)
  914. wait()
  915. else return false end
  916. else return false end
  917. end
  918. for i = 10, 0, -5 do
  919. if Player.Character:FindFirstChild("Torso") ~= nil then
  920. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  921. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new()
  922. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(-0.5, 1.2, 0.8) * CFrame.fromEulerAnglesXYZ(math.rad(300), math.rad(10 + i), math.rad(-90))
  923. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new()
  924. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(-0.9, -0.35, 0.51) * CFrame.fromEulerAnglesXYZ(math.rad(-90 - i), math.rad(-5), 0)
  925. wait()
  926. else return false end
  927. else return false end
  928. end
  929. Player.Character[Name].Bolt.Transparency = 1
  930. end
  931. return true
  932. end
  933.  
  934.  
  935. function CamShake(time, freq)
  936. coroutine.resume(coroutine.create(function()
  937. local cam = game:GetService("Workspace").CurrentCamera
  938. local time = 10
  939. local seed = Vector3.new(math.random(100, 200) / freq, math.random(100, 200) / freq, 0)
  940. if math.random(1, 2) == 1 then seed = Vector3.new(-seed.x, seed.y, 0) end
  941. if math.random(1, 2) == 1 then seed = Vector3.new(seed.x, -seed.y, 0) end
  942. cam.CoordinateFrame = (CFrame.new(cam.Focus.p) * (cam.CoordinateFrame - cam.CoordinateFrame.p) * CFrame.fromEulerAnglesXYZ(seed.x * time, seed.y * time, 0)) * CFrame.new(0, 0, (cam.CoordinateFrame.p - cam.Focus.p).magnitude)
  943. for i = 1, time do
  944. cam.CoordinateFrame = (CFrame.new(cam.Focus.p) * (cam.CoordinateFrame - cam.CoordinateFrame.p) * CFrame.fromEulerAnglesXYZ(-seed.x, -seed.y, 0)) * CFrame.new(0, 0, (cam.CoordinateFrame.p - cam.Focus.p).magnitude)
  945. wait()
  946. end
  947. end))
  948. end
  949.  
  950.  
  951. function makeShell(part)
  952. if part == nil then return false end
  953. local casing = Instance.new("Part")
  954. casing.Name = "Shell"
  955. casing.formFactor = "Custom"
  956. casing.Size = Vector3.new(0.2, 0.25, 0.2)
  957. casing.CFrame = CFrame.new(part.Position) * CFrame.fromEulerAnglesXYZ(math.rad(math.random(0, 360)), math.rad(math.random(0, 360)), math.rad(math.random(0, 360)))
  958. casing.BrickColor = BrickColor.new("White")
  959. local mesh = Instance.new("CylinderMesh")
  960. mesh.Scale = Vector3.new(0.6, 1, 0.6)
  961. mesh.Parent = casing
  962. casing.Parent = game:GetService("Workspace")
  963. casing:BreakJoints()
  964. casing.Velocity = (part.CFrame.lookVector * 50) + Vector3.new(-10, 0, 0)
  965. coroutine.resume(coroutine.create(function() wait(4.5) for i = 0, 1, 0.1 do casing.Transparency = i wait() end casing:Remove() end))
  966. end
  967.  
  968.  
  969. function Weld(x, y)
  970. local weld = Instance.new("Weld")
  971. weld.Part0 = x
  972. weld.Part1 = y
  973. CJ = CFrame.new(x.Position)
  974. C0 = x.CFrame:inverse() * CJ
  975. C1 = y.CFrame:inverse() * CJ
  976. weld.C0 = C0
  977. weld.C1 = C1
  978. weld.Parent = x
  979. end
  980.  
  981.  
  982. function tagHumanoid(humanoid)
  983. local tag = Instance.new("ObjectValue")
  984. tag.Name = "creator"
  985. tag.Value = Player
  986. tag.Parent = humanoid
  987. local tag = Instance.new("StringValue")
  988. tag.Name = "creatorType1"
  989. tag.Value = Name
  990. tag.Parent = humanoid
  991. local tag = Instance.new("StringValue")
  992. tag.Name = "creatorType2"
  993. tag.Value = "shot"
  994. tag.Parent = humanoid
  995. end
  996.  
  997.  
  998. function untagHumanoid(humanoid)
  999. if humanoid ~= nil then
  1000. local tag = humanoid:FindFirstChild("creator")
  1001. if tag ~= nil then
  1002. tag:Remove()
  1003. end
  1004. local tag = humanoid:FindFirstChild("creatorType1")
  1005. if tag ~= nil then
  1006. tag:Remove()
  1007. end
  1008. local tag = humanoid:FindFirstChild("creatorType2")
  1009. if tag ~= nil then
  1010. tag:Remove()
  1011. end
  1012. end
  1013. end
  1014.  
  1015.  
  1016. function fire(startPoint, endPoint, hit)
  1017. local trail = Instance.new("Part")
  1018. trail.Name = "Bullet Trail"
  1019. trail.BrickColor = BrickColor.new("Bright blue")
  1020. trail.TopSurface = 0
  1021. trail.BottomSurface = 0
  1022. trail.formFactor = 0
  1023. trail.Size = Vector3.new(1, 1, 1)
  1024. trail.Transparency = 0.8
  1025. trail.Reflectance = 0.35
  1026. trail.Anchored = true
  1027. trail.CanCollide = false
  1028. trail.CFrame = CFrame.new((startPoint + endPoint) / 2, endPoint)
  1029. trail.Parent = game:GetService("Workspace")
  1030. local mesh = Instance.new("SpecialMesh")
  1031. mesh.MeshType = "Brick"
  1032. mesh.Scale = Vector3.new(0.5, 0.5, (startPoint - endPoint).magnitude)
  1033. mesh.Parent = trail
  1034. coroutine.resume(coroutine.create(function(part) for i = 1, 10 do part.Mesh.Scale = Vector3.new(part.Mesh.Scale.x - 0.01, part.Mesh.Scale.y - 0.01, part.Mesh.Scale.z) wait() end part:Remove() end), trail)
  1035. if hit ~= nil then
  1036. if hit.Parent == nil then return end
  1037. if hit.Parent:FindFirstChild("Humanoid") ~= nil then
  1038. tagHumanoid(hit.Parent.Humanoid)
  1039. if hit.Name == "Head" then
  1040. hit.Parent.Humanoid:TakeDamage(damage * 10)
  1041. local e = Instance.new("Explosion")
  1042. e.BlastPressure = 10000000
  1043. e.BlastRadius = 4
  1044. e.Position = hit.Position
  1045. e.Parent = game:GetService("Workspace")
  1046. elseif hit.Name == "Torso" then
  1047. hit.Parent.Humanoid:TakeDamage(damage * 2)
  1048. local e = Instance.new("Explosion")
  1049. e.BlastPressure = 10000000
  1050. e.BlastRadius = 4
  1051. e.Position = hit.Position
  1052. e.Parent = game:GetService("Workspace")
  1053. else
  1054. hit.Parent.Humanoid:TakeDamage(damage)
  1055. local e = Instance.new("Explosion")
  1056. e.BlastPressure = 10000000
  1057. e.BlastRadius = 4
  1058. e.Position = hit.Position
  1059. e.Parent = game:GetService("Workspace")
  1060. end
  1061. if HP == true then
  1062. hit.Parent.Humanoid.Sit = true
  1063. end
  1064. delay(0.1, function() untagHumanoid(hit.Parent.Humanoid) end)
  1065. end
  1066. if hit.Anchored == false then
  1067. hit.Velocity = hit.Velocity + ((endPoint - startPoint).unit * (damage * 10))
  1068. end
  1069. end
  1070. end
  1071.  
  1072.  
  1073. function onButton1Down(mouse)
  1074. if selected == false then return end
  1075. if Player.Character:FindFirstChild(Name) ~= nil and Button1Down == false and canFire == true and (function() if dual == true then if Player.Character:FindFirstChild(Name.. " (Left)") ~= nil then return true else return false end else return true end end)() == true then
  1076. if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
  1077. if Player.Character[Name]:FindFirstChild("Muzzle") == nil then return end
  1078. if dual == true then if Player.Character[Name.. " (Left)"]:FindFirstChild("Handle") == nil then return end end
  1079. if dual == true then if Player.Character[Name.. " (Left)"]:FindFirstChild("Muzzle") == nil then return end end
  1080. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  1081. Button1Down = true
  1082. canFire = false
  1083. canFire2 = true
  1084. while canFire2 == true do
  1085. local humanoid = Player.Character:FindFirstChild("Humanoid")
  1086. if humanoid == nil then
  1087. canFire2 = false
  1088. break
  1089. end
  1090. if humanoid.Health <= 0 then
  1091. canFire2 = false
  1092. break
  1093. end
  1094. local fireLeft = false
  1095. if automatic == false and burst == false then
  1096. canFire2 = false
  1097. elseif automatic == false and burst == true then
  1098. if burstCount >= burstCountMax then
  1099. canFire2 = false
  1100. burstCount = 0
  1101. break
  1102. end
  1103. burstCount = burstCount + 1
  1104. elseif automatic == true and burst == false then
  1105. fireLeft = true
  1106. end
  1107. if magazine.Value > 0 then
  1108. magazine.Value = magazine.Value - 1
  1109. updateGui()
  1110. fire(Player.Character[Name].Muzzle.Position, mouse.Hit.p, mouse.Target)
  1111. coroutine.resume(coroutine.create(function()
  1112. if dual == true then
  1113. playAnimation("rightFire")
  1114. elseif dual == false then
  1115. playAnimation("fire")
  1116. end
  1117. end))
  1118. else
  1119. Player.Character[Name].Handle.Empty:Play()
  1120. --Player.Character[Name].BoltB.Transparency = 0
  1121. --Player.Character[Name].BoltC.Transparency = 1
  1122. end
  1123. if fireLeft == true and dual == true and automatic == true then
  1124. if magazine.Value > 0 then
  1125. coroutine.resume(coroutine.create(function()
  1126. wait(readyTime / 2)
  1127. magazine.Value = magazine.Value - 1
  1128. updateGui()
  1129. fire(Player.Character[Name.. " (Left)"].Muzzle.Position, mouse.Hit.p, mouse.Target)
  1130. playAnimation("leftFire")
  1131. end))
  1132. else
  1133. coroutine.resume(coroutine.create(function()
  1134. wait(readyTime / 2)
  1135. Player.Character[Name].Handle.Empty:Play()
  1136. end))
  1137. end
  1138. end
  1139. wait(readyTime)
  1140. end
  1141. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  1142. canFire = true
  1143. end
  1144. end
  1145.  
  1146.  
  1147. function onButton1Up(mouse)
  1148. if selected == false then return end
  1149. Button1Down = false
  1150. canFire2 = false
  1151. burstCount = 0
  1152. while canFire == false do wait() end
  1153. if dual == true and automatic == false then
  1154. if Player.Character[Name.. " (Left)"]:FindFirstChild("Handle") == nil then return end
  1155. if Player.Character[Name.. " (Left)"]:FindFirstChild("Muzzle") == nil then return end
  1156. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  1157. canFire = false
  1158. canFire2 = true
  1159. while canFire2 == true do
  1160. local humanoid = Player.Character:FindFirstChild("Humanoid")
  1161. if humanoid == nil then
  1162. canFire2 = false
  1163. break
  1164. end
  1165. if humanoid.Health <= 0 then
  1166. canFire2 = false
  1167. break
  1168. end
  1169. if burst == false then
  1170. canFire2 = false
  1171. elseif burst == true then
  1172. if burstCount >= burstCountMax then
  1173. canFire2 = false
  1174. burstCount = 0
  1175. break
  1176. end
  1177. burstCount = burstCount + 1
  1178. end
  1179. if magazine.Value <= 0 then
  1180. Player.Character[Name].Handle.Empty:Play()
  1181. else
  1182. coroutine.resume(coroutine.create(function()
  1183. playAnimation("leftFire")
  1184. end))
  1185. magazine.Value = magazine.Value - 1
  1186. updateGui()
  1187. fire(Player.Character[Name.. " (Left)"].Muzzle.Position, mouse.Hit.p, mouse.Target)
  1188. end
  1189. wait(readyTime)
  1190. end
  1191. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  1192. canFire = true
  1193. end
  1194. end
  1195.  
  1196.  
  1197. function onKeyDown(key, mouse)
  1198. if selected == false then return end
  1199. key = key:lower()
  1200. if key == "q" and Button1Down == false and canFire == true then
  1201. if mouse.Target == nil then return end
  1202. if game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent) ~= nil then
  1203. if dual == true then onKeyDown("t", mouse) end
  1204. onDeselected(mouse)
  1205. removeParts("RightHolster")
  1206. script.Parent.Parent = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent).Backpack
  1207. end
  1208. end
  1209. if key == "e" and Button1Down == false and canFire == true and canSilence == true then
  1210. if silenced then
  1211. silenced = false
  1212. if Player.Character:FindFirstChild(Name) == nil then return end
  1213. if Player.Character[Name]:FindFirstChild("Muzzle") == nil then return end
  1214. if Player.Character[Name]:FindFirstChild("Muzzle 2") == nil then return end
  1215. Player.Character[Name].Muzzle.Transparency = 1
  1216. Player.Character[Name].Muzzle.Name = "Silencer"
  1217. Player.Character[Name]["Muzzle 2"].Name = "Muzzle"
  1218. if dual == true then
  1219. if Player.Character[Name.. " (Left)"]:FindFirstChild("Muzzle") == nil then return end
  1220. if Player.Character[Name.. " (Left)"]:FindFirstChild("Muzzle 2") == nil then return end
  1221. Player.Character[Name.. " (Left)"].Muzzle.Transparency = 1
  1222. Player.Character[Name.. " (Left)"].Muzzle.Name = "Silencer"
  1223. Player.Character[Name.. " (Left)"]["Muzzle 2"].Name = "Muzzle"
  1224. end
  1225. else
  1226. silenced = true
  1227. if Player.Character:FindFirstChild(Name) == nil then return end
  1228. if Player.Character[Name]:FindFirstChild("Silencer") == nil then return end
  1229. if Player.Character[Name]:FindFirstChild("Muzzle") == nil then return end
  1230. Player.Character[Name].Silencer.Transparency = 0
  1231. Player.Character[Name].Muzzle.Name = "Muzzle 2"
  1232. Player.Character[Name].Silencer.Name = "Muzzle"
  1233. if dual == true then
  1234. if Player.Character[Name.. " (Left)"]:FindFirstChild("Silencer") == nil then return end
  1235. if Player.Character[Name.. " (Left)"]:FindFirstChild("Muzzle") == nil then return end
  1236. Player.Character[Name.. " (Left)"].Silencer.Transparency = 0
  1237. Player.Character[Name.. " (Left)"].Muzzle.Name = "Muzzle 2"
  1238. Player.Character[Name.. " (Left)"].Silencer.Name = "Muzzle"
  1239. end
  1240. end
  1241. end
  1242. if key == "r" and Button1Down == false and canFire == true then
  1243. if ammo.Value > 0 and magazine.Value ~= magazineMax.Value then
  1244. canFire = false
  1245. burstCount = 0
  1246. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  1247. if magazine.Value > 0 then ammo.Value = ammo.Value + magazine.Value magazine.Value = 0 end
  1248. updateGui()
  1249. if dual == true then
  1250. playAnimation("reloadDual")
  1251. elseif dual == false then
  1252. playAnimation("reload")
  1253. end
  1254. if ammo.Value - magazineMax.Value < 0 then
  1255. magazine.Value = ammo.Value
  1256. ammo.Value = 0
  1257. elseif ammo.Value - magazineMax.Value >= 0 then
  1258. ammo.Value = ammo.Value - magazineMax.Value
  1259. magazine.Value = magazineMax.Value
  1260. end
  1261. updateGui()
  1262. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  1263. canFire = true
  1264. end
  1265. end
  1266. if key == "t" and Button1Down == false and canFire == true and canDual == true then
  1267. canFire = false
  1268. if dual == false then
  1269. local weapon = nil
  1270. for _, p in pairs(Player.Backpack:GetChildren()) do
  1271. if p.Name == Name and p ~= script.Parent then weapon = p break end
  1272. end
  1273. if weapon ~= nil then
  1274. dual = true
  1275. weapon.Name = "Dual"
  1276. weapon.Parent = script
  1277. silenced = false
  1278. removeParts("RightHand")
  1279. makeParts("RightHand")
  1280. removeParts("RightHolster")
  1281. makeParts("LeftHolster")
  1282. playAnimation("leftEquip")
  1283. removeParts("LeftHolster")
  1284. makeParts("LeftHand")
  1285. magazineMax.Value = math.ceil(magazineMax.Value * 2)
  1286. ammoMax.Value = math.ceil(ammoMax.Value * 2)
  1287. magazine.Value = magazine.Value + weapon.Magazine.Value
  1288. ammo.Value = ammo.Value + weapon.Ammo.Value
  1289. updateGui()
  1290. end
  1291. elseif dual == true then
  1292. local weapon = script:FindFirstChild("Dual")
  1293. if weapon ~= nil then
  1294. dual = false
  1295. weapon.Name = Name
  1296. weapon.Parent = Player.Backpack
  1297. silenced = false
  1298. removeParts("RightHand")
  1299. makeParts("RightHand")
  1300. playAnimation("leftUnequip")
  1301. removeParts("LeftHand")
  1302. makeParts("RightHolster")
  1303. playAnimation("hold")
  1304. weapon.Magazine.Value = math.floor(magazine.Value / 2)
  1305. weapon.Ammo.Value = math.floor(ammo.Value / 2)
  1306. magazineMax.Value = math.ceil(magazineMax.Value / 2)
  1307. ammoMax.Value = math.ceil(ammoMax.Value / 2)
  1308. magazine.Value = math.ceil(magazine.Value / 2)
  1309. ammo.Value = math.ceil(ammo.Value / 2)
  1310. updateGui()
  1311. end
  1312. end
  1313. canFire = true
  1314. end
  1315. if key == "y" and canZoom == true then
  1316. if zoom == false then
  1317. zoom = true
  1318. local pos = mouse.Hit.p
  1319. local target = mouse.Target
  1320. local cam = game:GetService("Workspace").CurrentCamera
  1321. focus = Instance.new("Part", workspace)
  1322. focus.Anchored = true
  1323. focus.CanCollide = false
  1324. focus.Transparency = 1
  1325. focus.TopSurface = 0
  1326. focus.BottomSurface = 0
  1327. focus.formFactor = "Plate"
  1328. focus.Size = Vector3.new(0, 0, 0)
  1329. focus.CFrame = CFrame.new(pos) * (CFrame.new(Player.Character.Torso.CFrame.p, pos) - CFrame.new(Player.Character.Torso.CFrame.p, pos).p)
  1330. cam.CameraSubject = focus
  1331. cam.CameraType = "Attach"
  1332. while zoom == true and selected == true do
  1333. local set = false
  1334. if target ~= nil then
  1335. if target.Parent ~= nil then
  1336. if target.Anchored == false then
  1337. focus.CFrame = CFrame.new(target.CFrame.p) * (CFrame.new(Player.Character.Torso.CFrame.p, target.CFrame.p) - CFrame.new(Player.Character.Torso.CFrame.p, target.CFrame.p).p)
  1338. set = true
  1339. end
  1340. end
  1341. end
  1342. if set == false then
  1343. focus.CFrame = CFrame.new(pos) * (CFrame.new(Player.Character.Torso.CFrame.p, pos) - CFrame.new(Player.Character.Torso.CFrame.p, pos).p)
  1344. end
  1345. wait()
  1346. end
  1347. if focus ~= nil then focus:Remove() focus = nil end
  1348. local cam = game:GetService("Workspace").CurrentCamera
  1349. cam.CameraSubject = Player.Character:FindFirstChild("Humanoid")
  1350. cam.CameraType = "Custom"
  1351. else
  1352. zoom = false
  1353. end
  1354. end
  1355. if key == "u" and Button1Down == false and canFire == true then
  1356. if automatic == false and burst == false then
  1357. if switchToBurst == true then
  1358. burst = true
  1359. local m = Instance.new("Message", Player)
  1360. m.Text = "Burst"
  1361. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1362. delay(2.5, function() m:Remove() end)
  1363. elseif switchToAutomatic == true then
  1364. automatic = true
  1365. local m = Instance.new("Message", Player)
  1366. m.Text = "Automatic"
  1367. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1368. delay(2.5, function() m:Remove() end)
  1369. end
  1370. elseif automatic == false and burst == true then
  1371. if switchToAutomatic == true then
  1372. automatic = true
  1373. burst = false
  1374. local m = Instance.new("Message", Player)
  1375. m.Text = "Automatic"
  1376. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1377. delay(2.5, function() m:Remove() end)
  1378. elseif switchToSingle == true then
  1379. burst = false
  1380. local m = Instance.new("Message", Player)
  1381. m.Text = "Single"
  1382. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1383. delay(2.5, function() m:Remove() end)
  1384. end
  1385. elseif automatic == true and burst == false then
  1386. if switchToSingle == true then
  1387. automatic = false
  1388. local m = Instance.new("Message", Player)
  1389. m.Text = "Single"
  1390. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1391. delay(2.5, function() m:Remove() end)
  1392. elseif switchToBurst == true then
  1393. automatic = false
  1394. burst = true
  1395. local m = Instance.new("Message", Player)
  1396. m.Text = "Burst"
  1397. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1398. delay(2.5, function() m:Remove() end)
  1399. end
  1400. end
  1401. end
  1402. end
  1403.  
  1404.  
  1405. function onSelected(mouse)
  1406. if selected == true then return end
  1407. selected = true
  1408. canFire = false
  1409. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  1410. while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
  1411. if Player.Character.WeaponActivated.Value == nil then break end
  1412. if Player.Character.WeaponActivated.Value.Parent == nil then break end
  1413. wait()
  1414. end
  1415. updateGui()
  1416. local weapon = Instance.new("ObjectValue")
  1417. weapon.Name = "WeaponActivated"
  1418. weapon.Value = script.Parent
  1419. weapon.Parent = Player.Character
  1420. DisableLimb(1, Player.Character)
  1421. DisableLimb(2, Player.Character)
  1422. ForceAngle(1, 0, Player.Character)
  1423. ForceAngle(2, 0, Player.Character)
  1424. if dual == true then
  1425. coroutine.resume(coroutine.create(function() playAnimation("leftEquip") end))
  1426. playAnimation("rightEquip")
  1427. removeParts("LeftHolster")
  1428. makeParts("LeftHand")
  1429. else
  1430. playAnimation("equip")
  1431. end
  1432. removeParts("RightHolster")
  1433. makeParts("RightHand")
  1434. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  1435. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  1436. mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
  1437. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  1438. canFire = true
  1439. end
  1440.  
  1441.  
  1442. function onDeselected(mouse)
  1443. if selected == false then return end
  1444. Button1Down = false
  1445. while canFire == false do
  1446. wait()
  1447. end
  1448. selected = false
  1449. if dual == true then
  1450. if math.random(1, 2) == 1 then
  1451. coroutine.resume(coroutine.create(function() playAnimation("leftUnequip") end))
  1452. wait(math.random(1, 10) / 10)
  1453. playAnimation("rightUnequip")
  1454. else
  1455. coroutine.resume(coroutine.create(function() playAnimation("rightUnequip") end))
  1456. wait(math.random(1, 10) / 10)
  1457. playAnimation("leftUnequip")
  1458. end
  1459. removeParts("LeftHand")
  1460. makeParts("LeftHolster")
  1461. else
  1462. playAnimation("unequip")
  1463. end
  1464. removeParts("RightHand")
  1465. makeParts("RightHolster")
  1466. ForceAngle(1, 0, Player.Character)
  1467. ForceAngle(2, 0, Player.Character)
  1468. ResetLimbCFrame(1, Player.Character)
  1469. ResetLimbCFrame(2, Player.Character)
  1470. EnableLimb(1, Player.Character)
  1471. EnableLimb(2, Player.Character)
  1472. silenced = false
  1473. if Player.PlayerGui:FindFirstChild(Name) ~= nil then Player.PlayerGui[Name]:Remove() end
  1474. if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
  1475. if Player.Character.WeaponActivated.Value == script.Parent then
  1476. Player.Character.WeaponActivated:Remove()
  1477. end
  1478. end
  1479. while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
  1480. if Player.Character.WeaponActivated.Value == nil then break end
  1481. if Player.Character.WeaponActivated.Value.Parent == nil then break end
  1482. wait()
  1483. end
  1484. end
  1485.  
  1486.  
  1487. if script.Parent.ClassName ~= "HopperBin" then
  1488. if Player == nil then print("Error: Player not found!") return end
  1489. Tool = Instance.new("HopperBin")
  1490. Tool.Name = Name
  1491. Tool.Parent = Player.Backpack
  1492. script.Name = "Main"
  1493. script.Parent = Tool
  1494. end wait() if script.Parent.ClassName == "HopperBin" then
  1495. while script.Parent.Parent.ClassName ~= "Backpack" do
  1496. wait()
  1497. end
  1498. if script.Parent:FindFirstChild("MagazineMax") == nil then
  1499. magazineMax = Instance.new("NumberValue")
  1500. magazineMax.Name = "MagazineMax"
  1501. magazineMax.Value = 1
  1502. magazineMax.Parent = script.Parent
  1503. else
  1504. magazineMax = script.Parent.MagazineMax
  1505. end
  1506. if script.Parent:FindFirstChild("Magazine") == nil then
  1507. magazine = Instance.new("NumberValue")
  1508. magazine.Name = "Magazine"
  1509. magazine.Value = 0
  1510. magazine.Parent = script.Parent
  1511. else
  1512. magazine = script.Parent.Magazine
  1513. end
  1514. if script.Parent:FindFirstChild("AmmoMax") == nil then
  1515. ammoMax = Instance.new("NumberValue")
  1516. ammoMax.Name = "AmmoMax"
  1517. ammoMax.Value = 21
  1518. ammoMax.Parent = script.Parent
  1519. else
  1520. ammoMax = script.Parent.AmmoMax
  1521. end
  1522. if script.Parent:FindFirstChild("Ammo") == nil then
  1523. ammo = Instance.new("NumberValue")
  1524. ammo.Name = "Ammo"
  1525. ammo.Value = script.Parent.AmmoMax.Value
  1526. ammo.Parent = script.Parent
  1527. else
  1528. ammo = script.Parent.Ammo
  1529. end
  1530. Player = script.Parent.Parent.Parent
  1531. makeParts("RightHolster")
  1532. script.Parent.Selected:connect(onSelected)
  1533. script.Parent.Deselected:connect(onDeselected)
  1534. end
Add Comment
Please, Sign In to add comment