Advertisement
thetacolord609

Untitled

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