Advertisement
Guest User

cannon

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