Advertisement
memberhero

Untitled

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