AMisspelledUsernaem

SubspaceTripmine

Jun 4th, 2023 (edited)
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.75 KB | None | 0 0
  1. coroutine.wrap(function()
  2. local tool=Instance.new('Tool')
  3. local handle=Instance.new('Part',tool)
  4. local mesh=Instance.new('SpecialMesh',handle)
  5.  
  6. mesh.TextureId='http://www.roblox.com/asset/?id=11954766'
  7. mesh.MeshId='http://www.roblox.com/asset/?id=11954776'
  8. mesh.Scale=Vector3.one*.7
  9.  
  10. handle.Size=Vector3.new(2,2,2)
  11. handle.Color=Color3.fromRGB(255,0,191)
  12. handle.Name='Handle'
  13.  
  14. tool.Grip=CFrame.new(-.5,0,0)*CFrame.Angles(0,math.rad(-90),0)
  15. tool.Name='SubspaceTripmine'
  16. tool.TextureId='http://www.roblox.com/asset/?id=11987521'
  17.  
  18. local script=Instance.new('Script',tool)
  19. script.Name='PlantBomb'
  20.  
  21. local function SubspaceMine(script)
  22.     local Mine = script.Parent
  23.     local DunDun = Instance.new("Sound")
  24.     DunDun.SoundId = "http://www.roblox.com/asset/?id=11984254"
  25.     DunDun.Parent = Mine
  26.     local SubspaceExplosion = Instance.new("Sound")
  27.     SubspaceExplosion.SoundId = "http://www.roblox.com/asset/?id=11984351"
  28.     SubspaceExplosion.Parent = Mine
  29.     local Calibrate = Instance.new("Sound")
  30.     Calibrate.SoundId = "http://www.roblox.com/asset/?id=11956590"
  31.     Calibrate.Looped = true
  32.     Calibrate.Parent = Mine
  33.     Calibrate:Play()
  34.     local calibration_time = 2 -- needs to be still/untouched for this long before calibrating
  35.     local cur_time = 0
  36.     local max_life = 120 -- these things last for 2 minutes on their own, once activated
  37.     local calibrated = false
  38.     local connection = nil
  39.     local function activateMine()
  40.         for i=0,1,-.1 do
  41.             Mine.Transparency = i
  42.             wait(.05)
  43.         end
  44.         calibrated = true
  45.         Calibrate:Stop()
  46.     end
  47.     local function pulse()
  48.         DunDun:Play()
  49.         for i=.9,.5,-.1 do
  50.             Mine.Transparency = i
  51.             wait(.05)
  52.         end
  53.         for i=.5,1,.1 do
  54.             Mine.Transparency = i
  55.             wait(.05)
  56.         end
  57.     end
  58.     local function onPlayerBlownUp(part, distance, creator)
  59.         if (part:getMass() < 300) then
  60.             part.BrickColor = BrickColor.new(1032)
  61.             local s = Instance.new("Sparkles")
  62.             s.Parent = part
  63.             game.Debris:AddItem(s, 5)
  64.         end
  65.         if creator ~= nil and part.Name == "Head" then
  66.             local humanoid = part.Parent.Humanoid
  67.             tagHumanoid(humanoid, creator)
  68.         end
  69.     end
  70.     local function explode()
  71.         connection:disconnect()
  72.         for i=1,0,-.2 do
  73.             Mine.Transparency = i
  74.             wait(.05)
  75.         end
  76.         SubspaceExplosion:Play()
  77.         local e = Instance.new("Explosion")
  78.         e.BlastRadius = 16
  79.         e.BlastPressure = 1000000
  80.         e.Position = Mine.Position
  81.         e.Parent = Mine
  82.         local creator = script.Parent:findFirstChild("creator")
  83.         e.Hit:connect(function(part, distance)  onPlayerBlownUp(part, distance, creator) end)
  84.         for i=0,1,.2 do
  85.             Mine.Transparency = i
  86.             task.wait(.05)
  87.         end
  88.         task.wait(4)
  89.         Mine:Remove()
  90.     end
  91.     local function update()
  92.         if (calibrated == false) then
  93.             if (Mine.Velocity.magnitude > .1) then
  94.                 cur_time = 0
  95.             end
  96.             if (cur_time > calibration_time) then
  97.                 activateMine()
  98.             end
  99.         else
  100.             -- calibrated mine
  101.             if (math.random(1,20) == 2) then
  102.                 pulse()
  103.             end
  104.             if (cur_time > max_life) then pulse() Mine:Remove() end
  105.         end
  106.     end
  107.     local function OnTouch(part)
  108.         if (calibrated == false) then
  109.             cur_time = 0
  110.         else
  111.             explode()
  112.         end
  113.     end
  114.     local function tagHumanoid(humanoid, creator)
  115.         -- tag does not need to expire iff all explosions lethal
  116.         if creator ~= nil then
  117.             local new_tag = creator:clone()
  118.             new_tag.Parent = humanoid
  119.         end
  120.     end
  121.     local function untagHumanoid(humanoid)
  122.         if humanoid ~= nil then
  123.             local tag = humanoid:findFirstChild("creator")
  124.             if tag ~= nil then
  125.                 tag.Parent = nil
  126.             end
  127.         end
  128.     end
  129.     connection = Mine.Touched:connect(OnTouch)
  130.     while true do
  131.         update()
  132.         local e,g = wait(.5)
  133.         cur_time = cur_time + e
  134.     end
  135. end
  136. Tool = script.Parent
  137. function plant(pos)
  138.     local vCharacter = Tool.Parent
  139.     local vPlayer = game.Players:playerFromCharacter(vCharacter)
  140.     local spawnPos = vCharacter.PrimaryPart.Position
  141.     local bomb = Tool.Handle:Clone()
  142.     bomb.CanCollide = true
  143.     bomb.Transparency = 0
  144.     bomb.Position = pos
  145.     bomb.Size = Vector3.new(2,2,2)
  146.     bomb.Name = "SubspaceTripmine"
  147.     bomb.Locked = true
  148.     local creator_tag = Instance.new("ObjectValue")
  149.     creator_tag.Value = vPlayer
  150.     creator_tag.Name = "creator"
  151.     creator_tag.Parent = bomb
  152.     bomb.Parent = game.Workspace
  153.     local new_script = Instance.new('Script',bomb)
  154.     new_script.Disabled = false
  155.     new_script.Parent = bomb
  156.     task.spawn(SubspaceMine,new_script)
  157. end
  158. Tool.Enabled = true
  159. function onActivated()
  160.     if not Tool.Enabled then
  161.         return
  162.     end
  163.     Tool.Enabled = false
  164.     local character = Tool.Parent;
  165.     local humanoid = character.Humanoid
  166.     if humanoid == nil then
  167.         print("Humanoid not found")
  168.         return
  169.     end
  170.     local targetPos = humanoid.TargetPoint
  171.     Tool.Handle.Transparency = 1
  172.     plant(Tool.Handle.Position)
  173.     Tool.Handle.Transparency = 0
  174.     Tool.Enabled = true
  175. end
  176.  
  177. tool.Parent=owner:WaitForChild("Backpack")
  178.  
  179. script.Parent.Activated:connect(onActivated)
  180. end)()
Advertisement
Add Comment
Please, Sign In to add comment