Advertisement
IHackShootingGames

Untitled

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