Advertisement
memberhero

Untitled

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