Advertisement
astronaut32

frag

Dec 14th, 2016
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.48 KB | None | 0 0
  1. --[[
  2. M67 Fragmentation Grenade. Pull the pin / Drop it in / Let it wash away their sins.
  3. --]]
  4.  
  5.  
  6. if script == nil then return end
  7.  
  8.  
  9. Player = game.Players.LocalPlayer
  10. Char = Player.Character
  11. animate = Char:findFirstChild("Animate")
  12. if animate then
  13. animate:Destroy()
  14. end
  15. Name = "M67 Frag"
  16. selected = false
  17. Button1Down = false
  18. thrown = false
  19.  
  20.  
  21. function makeParts(format)
  22. local grenade = Instance.new("Model")
  23. grenade.Name = Name
  24. grenade.Parent = Player.Character
  25. local pm = Instance.new("Part")
  26. pm.Name = "Handle"
  27. pm.formFactor = "Symmetric"
  28. pm.Size = Vector3.new(1, 1, 1)
  29. pm.BrickColor = BrickColor.new("Camo")
  30. pm.Locked = true
  31. pm.TopSurface = 0
  32. pm.BottomSurface = 0
  33. pm.Parent = grenade
  34. local m = Instance.new("SpecialMesh")
  35. m.MeshType = "Sphere"
  36. m.Scale = Vector3.new(0.6, 0.7, 0.6)
  37. m.Parent = pm
  38. local w = Instance.new("Weld")
  39. w.Part0 = pm
  40. if format == "hand" then
  41. w.Part1 = Player.Character:FindFirstChild("Right Arm")
  42. w.C0 = CFrame.new(-1.2, 0, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, math.rad(90))
  43. w.C1 = CFrame.new()
  44. elseif format == "holster" then
  45. w.Part1 = Player.Character:FindFirstChild("Torso")
  46. w.C0 = CFrame.new(-0.5, 0.68, 0.55) * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(-6))
  47. w.C1 = CFrame.new()
  48. grenade.Name = Name.. " (Holstered)"
  49. end
  50. w.Parent = pm
  51. local s = Instance.new("Sound")
  52. s.Name = "Explode"
  53. s.SoundId = "rbxasset://sounds\\collide.wav"
  54. s.Volume = 1
  55. s.Pitch = 1
  56. s.Looped = false
  57. s.Parent = pm
  58. local s = Instance.new("Sound")
  59. s.Name = "Ready"
  60. s.SoundId = "http://www.roblox.com/Asset/?id=2697295"
  61. s.Volume = 1
  62. s.Pitch = 2
  63. s.Looped = false
  64. s.Parent = pm
  65. local s = Instance.new("Sound")
  66. s.Name = "Pin"
  67. s.SoundId = "http://www.roblox.com/Asset/?id=10209636"
  68. s.Volume = 1
  69. s.Pitch = 2
  70. s.Looped = false
  71. s.Parent = pm
  72. local p = Instance.new("Part")
  73. p.Name = "Pin Holder"
  74. p.formFactor = "Symmetric"
  75. p.Size = Vector3.new(1, 1, 1)
  76. p.BrickColor = BrickColor.new("Dark stone grey")
  77. p.CanCollide = false
  78. p.Transparency = 0
  79. p.Locked = true
  80. p.TopSurface = 0
  81. p.BottomSurface = 0
  82. p.Parent = grenade
  83. local m = Instance.new("CylinderMesh")
  84. m.Scale = Vector3.new(0.22, 0.2, 0.22)
  85. m.Parent = p
  86. local w = Instance.new("Weld")
  87. w.Part0 = p
  88. w.Part1 = pm
  89. w.C0 = CFrame.new(0, -0.5, 0)
  90. w.C1 = CFrame.new()
  91. w.Parent = p
  92. local p = Instance.new("Part")
  93. p.Name = "Pin Holder 2"
  94. p.formFactor = "Symmetric"
  95. p.Size = Vector3.new(1, 1, 1)
  96. p.BrickColor = BrickColor.new("Camo")
  97. p.CanCollide = false
  98. p.Transparency = 0
  99. p.Locked = true
  100. p.TopSurface = 0
  101. p.BottomSurface = 0
  102. p.Parent = grenade
  103. local m = Instance.new("CylinderMesh")
  104. m.Scale = Vector3.new(0.2, 0.2, 0.2)
  105. m.Parent = p
  106. local w = Instance.new("Weld")
  107. w.Part0 = p
  108. w.Part1 = pm
  109. w.C0 = CFrame.new(0, -0.3, 0)
  110. w.C1 = CFrame.new()
  111. w.Parent = p
  112. local p = Instance.new("Part")
  113. p.Name = "Clamp"
  114. p.formFactor = "Symmetric"
  115. p.Size = Vector3.new(1, 1, 1)
  116. p.BrickColor = BrickColor.new("Black")
  117. p.CanCollide = false
  118. p.Transparency = 0
  119. p.Locked = true
  120. p.TopSurface = 0
  121. p.BottomSurface = 0
  122. p.Parent = grenade
  123. local m = Instance.new("SpecialMesh")
  124. m.MeshType = "FileMesh"
  125. m.MeshId = "http://www.roblox.com/asset/?id=3270017"
  126. m.Scale = Vector3.new(0.45, 0.5, 0.8)
  127. m.Parent = p
  128. local w = Instance.new("Weld")
  129. w.Part0 = p
  130. w.Part1 = pm
  131. w.C0 = CFrame.new(0.12, -0.18, 0)
  132. w.C1 = CFrame.new()
  133. w.Parent = p
  134. local pm2 = Instance.new("Part")
  135. pm2.Name = "Pin"
  136. pm2.formFactor = "Symmetric"
  137. pm2.Size = Vector3.new(1, 1, 1)
  138. pm2.BrickColor = BrickColor.new("Dark stone grey")
  139. pm2.Transparency = 0
  140. pm2.Locked = true
  141. pm2.TopSurface = 0
  142. pm2.BottomSurface = 0
  143. pm2.Parent = grenade
  144. local m = Instance.new("SpecialMesh")
  145. m.MeshType = "FileMesh"
  146. m.MeshId = "http://www.roblox.com/asset/?id=3270017"
  147. m.Scale = Vector3.new(0.2, 0.2, 0.4)
  148. m.Parent = pm2
  149. local w = Instance.new("Weld")
  150. w.Part0 = pm2
  151. w.Part1 = pm
  152. w.C0 = CFrame.new(0.15, -0.6, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  153. w.C1 = CFrame.new()
  154. w.Parent = pm2
  155. end
  156.  
  157.  
  158. function removeParts(format)
  159. if format == "hand" then
  160. if Player.Character:FindFirstChild(Name) ~= nil then
  161. Player.Character[Name]:Remove()
  162. end
  163. elseif format == "holster" then
  164. if Player.Character:FindFirstChild(Name.. " (Holstered)") ~= nil then
  165. Player.Character[Name.. " (Holstered)"]:Remove()
  166. end
  167. end
  168. end
  169.  
  170.  
  171. function SetAngle(Joint, Angle, Character)
  172. if Character == nil then return false end
  173. local Joints = {
  174. Character.Torso:FindFirstChild("Right Shoulder 2"),
  175. Character.Torso:FindFirstChild("Left Shoulder 2"),
  176. Character.Torso:FindFirstChild("Right Hip 2"),
  177. Character.Torso:FindFirstChild("Left Hip 2")
  178. }
  179. if Joints[Joint] == nil then return false end
  180. if Joint == 1 or Joint == 3 then
  181. Joints[Joint].DesiredAngle = Angle
  182. end
  183. if Joint == 2 or Joint == 4 then
  184. Joints[Joint].DesiredAngle = -Angle
  185. end
  186. end
  187.  
  188.  
  189. function ForceAngle(Joint, Angle, Character)
  190. if Character == nil then return false end
  191. local Joints = {
  192. Character.Torso:FindFirstChild("Right Shoulder 2"),
  193. Character.Torso:FindFirstChild("Left Shoulder 2"),
  194. Character.Torso:FindFirstChild("Right Hip 2"),
  195. Character.Torso:FindFirstChild("Left Hip 2")
  196. }
  197. if Joints[Joint] == nil then return false end
  198. if Joint == 1 or Joint == 3 then
  199. Joints[Joint].DesiredAngle = Angle
  200. Joints[Joint].CurrentAngle = Angle
  201. end
  202. if Joint == 2 or Joint == 4 then
  203. Joints[Joint].DesiredAngle = -Angle
  204. Joints[Joint].CurrentAngle = -Angle
  205. end
  206. end
  207.  
  208.  
  209. function SetSpeed(Joint, Speed, Character)
  210. if Character == nil then return false end
  211. local Joints = {
  212. Character.Torso:FindFirstChild("Right Shoulder 2"),
  213. Character.Torso:FindFirstChild("Left Shoulder 2"),
  214. Character.Torso:FindFirstChild("Right Hip 2"),
  215. Character.Torso:FindFirstChild("Left Hip 2")
  216. }
  217. if Joints[Joint] == nil then return false end
  218. Joints[Joint].MaxVelocity = Speed
  219. end
  220.  
  221.  
  222. function DisableLimb(Limb, Character)
  223. if Character == nil then return false end
  224. if Character:FindFirstChild("Torso") == nil then return false end
  225. local Joints = {
  226. Character.Torso:FindFirstChild("Right Shoulder"),
  227. Character.Torso:FindFirstChild("Left Shoulder"),
  228. Character.Torso:FindFirstChild("Right Hip"),
  229. Character.Torso:FindFirstChild("Left Hip")
  230. }
  231. local Limbs = {
  232. Character:FindFirstChild("Right Arm"),
  233. Character:FindFirstChild("Left Arm"),
  234. Character:FindFirstChild("Right Leg"),
  235. Character:FindFirstChild("Left Leg")
  236. }
  237. if Joints[Limb] == nil then return false end
  238. if Limbs[Limb] == nil then return false end
  239. local Joint = Instance.new("Motor")
  240. Joint.Parent = Character.Torso
  241. Joint.Part0 = Character.Torso
  242. Joint.Part1 = Limbs[Limb]
  243. if Limb == 1 then
  244. Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  245. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  246. Joint.Name = "Right Shoulder 2"
  247. elseif Limb == 2 then
  248. Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  249. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  250. Joint.Name = "Left Shoulder 2"
  251. elseif Limb == 3 then
  252. Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  253. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  254. Joint.Name = "Right Hip 2"
  255. elseif Limb == 4 then
  256. Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  257. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  258. Joint.Name = "Left Hip 2"
  259. end
  260. Joint.MaxVelocity = Joints[Limb].MaxVelocity
  261. Joint.CurrentAngle = Joints[Limb].CurrentAngle
  262. Joint.DesiredAngle = Joints[Limb].DesiredAngle
  263. Joints[Limb]:Remove()
  264. end
  265.  
  266.  
  267. function ResetLimbCFrame(Limb, Character)
  268. if Character == nil then return false end
  269. if Character.Parent == nil then return false end
  270. if Character:FindFirstChild("Torso") == nil then return false end
  271. local Joints = {
  272. Character.Torso:FindFirstChild("Right Shoulder 2"),
  273. Character.Torso:FindFirstChild("Left Shoulder 2"),
  274. Character.Torso:FindFirstChild("Right Hip 2"),
  275. Character.Torso:FindFirstChild("Left Hip 2")
  276. }
  277. local Limbs = {
  278. Character:FindFirstChild("Right Arm"),
  279. Character:FindFirstChild("Left Arm"),
  280. Character:FindFirstChild("Right Leg"),
  281. Character:FindFirstChild("Left Leg")
  282. }
  283. if Joints[Limb] == nil then return false end
  284. if Limbs[Limb] == nil then return false end
  285. if Limb == 1 then
  286. Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  287. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  288. elseif Limb == 2 then
  289. Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  290. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  291. elseif Limb == 3 then
  292. Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  293. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  294. elseif Limb == 4 then
  295. Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  296. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  297. end
  298. end
  299.  
  300.  
  301. function EnableLimb(Limb, Character)
  302. if Character == nil then return false end
  303. if Character:FindFirstChild("Torso") == nil then return false end
  304. local Joints = {
  305. Character.Torso:FindFirstChild("Right Shoulder 2"),
  306. Character.Torso:FindFirstChild("Left Shoulder 2"),
  307. Character.Torso:FindFirstChild("Right Hip 2"),
  308. Character.Torso:FindFirstChild("Left Hip 2")
  309. }
  310. local Limbs = {
  311. Character:FindFirstChild("Right Arm"),
  312. Character:FindFirstChild("Left Arm"),
  313. Character:FindFirstChild("Right Leg"),
  314. Character:FindFirstChild("Left Leg")
  315. }
  316. if Joints[Limb] == nil then return false end
  317. if Limbs[Limb] == nil then return false end
  318. if Limb == 1 then
  319. Joints[Limb].Name = "Right Shoulder"
  320. elseif Limb == 2 then
  321. Joints[Limb].Name = "Left Shoulder"
  322. elseif Limb == 3 then
  323. Joints[Limb].Name = "Right Hip"
  324. elseif Limb == 4 then
  325. Joints[Limb].Name = "Left Hip"
  326. end
  327. Animate = Character:FindFirstChild("Animate")
  328. if Animate == nil then return false end
  329. Animate = Animate:Clone()
  330. Character.Animate:Remove()
  331. Animate.Parent = Character
  332. end
  333.  
  334.  
  335. function Weld(x, y)
  336. local weld = Instance.new("Weld")
  337. weld.Part0 = x
  338. weld.Part1 = y
  339. CJ = CFrame.new(x.Position)
  340. C0 = x.CFrame:inverse() * CJ
  341. C1 = y.CFrame:inverse() * CJ
  342. weld.C0 = C0
  343. weld.C1 = C1
  344. weld.Parent = x
  345. end
  346.  
  347.  
  348. function tagHumanoid(humanoid)
  349. local tag = Instance.new("ObjectValue")
  350. tag.Name = "creator"
  351. tag.Value = Player
  352. tag.Parent = humanoid
  353. local tag = Instance.new("StringValue")
  354. tag.Name = "creatorType1"
  355. tag.Value = Name
  356. tag.Parent = humanoid
  357. local tag = Instance.new("StringValue")
  358. tag.Name = "creatorType2"
  359. tag.Value = "blown up"
  360. tag.Parent = humanoid
  361. end
  362.  
  363.  
  364. function untagHumanoid(humanoid)
  365. if humanoid ~= nil then
  366. local tag = humanoid:FindFirstChild("creator")
  367. if tag ~= nil then
  368. tag:Remove()
  369. end
  370. local tag = humanoid:FindFirstChild("creatorType1")
  371. if tag ~= nil then
  372. tag:Remove()
  373. end
  374. local tag = humanoid:FindFirstChild("creatorType2")
  375. if tag ~= nil then
  376. tag:Remove()
  377. end
  378. end
  379. end
  380.  
  381.  
  382. function fire(v)
  383. if Player.Character:FindFirstChild(Name) == nil then makeParts("hand") end
  384. if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
  385. if Player.Character[Name].Handle:FindFirstChild("Weld") ~= nil then Player.Character[Name].Handle.Weld:Remove() end
  386. local bodyVelocity = Instance.new("BodyVelocity")
  387. bodyVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  388. bodyVelocity.velocity = v * 75
  389. bodyVelocity.Parent = Player.Character[Name].Handle
  390. wait(0.1)
  391. bodyVelocity:Remove()
  392. end
  393.  
  394.  
  395. function onButton1Down(mouse)
  396. if selected == false then return end
  397. if Player.Character:FindFirstChild(Name) ~= nil and Button1Down ~= true and thrown ~= true then
  398. if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
  399. if Player.Character[Name]:FindFirstChild("Pin") == nil then return end
  400. Button1Down = true
  401. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  402. if Player.Character[Name].Pin:FindFirstChild("Weld") ~= nil then Player.Character[Name].Pin.Weld:Remove() end
  403. Player.Character[Name].Handle.Pin:Play()
  404. Player.Character[Name].Handle.CanCollide = true
  405. wait(0.2)
  406. Player.Character[Name].Handle.Ready:Play()
  407. coroutine.resume(coroutine.create(function()
  408. wait(3)
  409. if Player.Character:FindFirstChild(Name) ~= nil then
  410. if Player.Character[Name]:FindFirstChild("Handle") ~= nil then
  411. local e = Instance.new("Explosion")
  412. e.BlastPressure = 1000000
  413. e.BlastRadius = 20
  414. e.Position = Player.Character[Name].Handle.Position
  415. e.Parent = game:GetService("Workspace")
  416. e.Hit:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then tagHumanoid(hit.Parent.Humanoid) delay(1, function() untagHumanoid(hit.Parent.Humanoid) end) end end)
  417. Player.Character[Name].Handle.Explode:Play()
  418. Player.Character[Name].Handle.Transparency = 1
  419. Player.Character[Name].Handle.CanCollide = false
  420. end
  421. end
  422. wait()
  423. if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
  424. Player.Character.WeaponActivated:Remove()
  425. end
  426. thrown = false
  427. Button1Down = false
  428. selected = true
  429. onDeselected(mouse)
  430. removeParts("holster")
  431. script.Parent:Remove()
  432. end))
  433. end
  434. end
  435.  
  436.  
  437. function onButton1Up(mouse)
  438. if selected == false then return end
  439. if Button1Down == true and thrown ~= true then
  440. thrown = true
  441. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  442. SetSpeed(1, 2, Player.Character)
  443. SetAngle(1, 0, Player.Character)
  444. EnableLimb(1, Player.Character)
  445. fire((mouse.Hit.p - Player.Character[Name].Handle.Position).unit)
  446. end
  447. Button1Down = false
  448. end
  449.  
  450.  
  451. function onKeyDown(key, mouse)
  452. if selected == false then return end
  453. key = key:lower()
  454. if key == "q" and Button1Down == false and thrown ~= true then
  455. if mouse.Target == nil then return end
  456. if game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent) ~= nil then
  457. onDeselected(mouse)
  458. removeParts("holster")
  459. script.Parent.Parent = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent).Backpack
  460. end
  461. end
  462. end
  463.  
  464.  
  465. function onSelected(mouse)
  466. if selected == true then return end
  467. selected = true
  468. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  469. while Player.Character:FindFirstChild("WeaponActivated") ~= nil or thrown == true do
  470. if Player.Character.WeaponActivated.Value == nil then break end
  471. if Player.Character.WeaponActivated.Value.Parent == nil then break end
  472. wait()
  473. end
  474. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  475. removeParts("holster")
  476. makeParts("hand")
  477. local weapon = Instance.new("ObjectValue")
  478. weapon.Name = "WeaponActivated"
  479. weapon.Value = script.Parent
  480. weapon.Parent = Player.Character
  481. DisableLimb(1, Player.Character)
  482. SetAngle(1, math.rad(200), Player.Character)
  483. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  484. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  485. mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
  486. end
  487.  
  488.  
  489. function onDeselected(mouse)
  490. if selected == false then return end
  491. selected = false
  492. while Button1Down == true or thrown == true do
  493. wait()
  494. end
  495. if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
  496. if Player.Character.WeaponActivated.Value == script.Parent then
  497. Player.Character.WeaponActivated:Remove()
  498. end
  499. end
  500. while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
  501. if Player.Character.WeaponActivated.Value == nil then break end
  502. if pcall(function() if Player.Character.WeaponActivated.Value.Parent == nil then return true end end) then break end
  503. wait()
  504. end
  505. removeParts("hand")
  506. makeParts("holster")
  507. SetAngle(1, 0, Player.Character)
  508. EnableLimb(1, Player.Character)
  509. end
  510.  
  511.  
  512. if script.Parent.ClassName ~= "HopperBin" then
  513. if Player == nil then print("Error: Player not found!") return end
  514. Tool = Instance.new("HopperBin")
  515. Tool.Name = Name
  516. Tool.Parent = Player.Backpack
  517. script.Name = "Main"
  518. script.Parent = Tool
  519. end wait() if script.Parent.ClassName == "HopperBin" then
  520. while script.Parent.Parent.ClassName ~= "Backpack" do
  521. wait()
  522. end
  523. Player = script.Parent.Parent.Parent
  524. makeParts("holster")
  525. script.Parent.Selected:connect(onSelected)
  526. script.Parent.Deselected:connect(onDeselected)
  527. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement