Advertisement
memberhero

Untitled

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