Advertisement
KrYn0MoRe

subspace tripmine gear

Feb 20th, 2023 (edited)
1,247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.29 KB | None | 0 0
  1. Tool = Instance.new("Tool")
  2. Tool.Name = 'Subspace Tripmine'
  3. Tool.CanBeDropped = true
  4. Tool.RequiresHandle = true
  5.  
  6. Part0 = Instance.new("Part")
  7. SpecialMesh1 = Instance.new("SpecialMesh")
  8. Part0.Name = "Handle"
  9. Part0.Parent = Tool
  10. Part0.CFrame = CFrame.new(7, 1.39097822, 3, 1, -5.50079088e-19, 5.6767685e-24, 5.50079088e-19, 1, -5.50079088e-19, -5.6767685e-24, 5.50079088e-19, 1)
  11. Part0.Position = Vector3.new(7, 1.390978217124939, 3)
  12. Part0.Color = Color3.new(1, 0, 0.74902)
  13. Part0.Velocity = Vector3.new(-2.0073717184513294e-18, -0.009398775175213814, 2.100645224708268e-18)
  14. Part0.Size = Vector3.new(2, 2, 2)
  15. Part0.BottomSurface = Enum.SurfaceType.Smooth
  16. Part0.BrickColor = BrickColor.new("Hot pink")
  17. Part0.RotVelocity = Vector3.new(2.05534653961818e-18, 8.374077637867082e-21, 2.05534653961818e-18)
  18. Part0.TopSurface = Enum.SurfaceType.Smooth
  19. Part0.brickColor = BrickColor.new("Hot pink")
  20. SpecialMesh1.Parent = Part0
  21. SpecialMesh1.MeshId = "http://www.roblox.com/asset/?id=11954776"
  22. SpecialMesh1.Scale = Vector3.new(0.699999988079071, 0.699999988079071, 0.699999988079071)
  23. SpecialMesh1.TextureId = "http://www.roblox.com/asset/?id=11954766"
  24. SpecialMesh1.MeshType = Enum.MeshType.FileMesh
  25.  
  26. wait = task.wait
  27.  
  28. function runmine(Mine)
  29.     local DunDun = Instance.new("Sound")
  30.     DunDun.SoundId = "http://www.roblox.com/asset/?id=11984254"
  31.     DunDun.Parent = Mine
  32.  
  33.     local SubspaceExplosion = Instance.new("Sound")
  34.     SubspaceExplosion.SoundId = "http://www.roblox.com/asset/?id=11984351"
  35.     SubspaceExplosion.Parent = Mine
  36.  
  37.     local Calibrate = Instance.new("Sound")
  38.     Calibrate.SoundId = "http://www.roblox.com/asset/?id=11956590"
  39.     Calibrate.Looped = true
  40.     Calibrate.Parent = Mine
  41.     Calibrate:Play()
  42.  
  43.     local calibration_time = 2 -- needs to be still/untouched for this long before calibrating
  44.     local cur_time = 0
  45.     local max_life = 120 -- these things last for 2 minutes on their own, once activated
  46.     local calibrated = false
  47.     local looping = true
  48.  
  49.     local connection = nil
  50.    
  51.     local function activateMine()
  52.         for i=0,1,-.1 do
  53.             Mine.Transparency = i
  54.             wait(.05)
  55.         end
  56.         calibrated = true
  57.         Calibrate:Stop()
  58.     end
  59.     local function pulse()
  60.         DunDun:Play()
  61.         for i=.9,.5,-.1 do
  62.             Mine.Transparency = i
  63.             wait(.05)
  64.         end
  65.  
  66.         for i=.5,1,.1 do
  67.             Mine.Transparency = i
  68.             wait(.05)
  69.         end
  70.     end
  71.     local function tagHumanoid(humanoid, creator)
  72.         if creator ~= nil then
  73.             local new_tag = creator:clone()
  74.             new_tag.Parent = humanoid
  75.         end
  76.     end
  77.     local function untagHumanoid(humanoid)
  78.         if humanoid ~= nil then
  79.             local tag = humanoid:FindFirstChild("creator")
  80.             if tag ~= nil then
  81.                 tag.Parent = nil
  82.             end
  83.         end
  84.     end
  85.     local function onPlayerBlownUp(part, distance, creator)
  86.         if part:IsA("BasePart") and not part:IsA("SpawnLocation") and (part:GetMass() < 300) then
  87.             part.BrickColor = BrickColor.new(1032)
  88.             local s = Instance.new("Sparkles")
  89.             s.Parent = part
  90.             game.Debris:AddItem(s, 5)
  91.         end
  92.         if creator ~= nil and part.Name == "Head" then
  93.             local humanoid = part.Parent.Humanoid
  94.             tagHumanoid(humanoid, creator)
  95.         end
  96.     end
  97.     local function explode()
  98.         connection:Disconnect()
  99.  
  100.         for i=1,0,-.2 do
  101.             Mine.Transparency = i
  102.             wait(.05)
  103.         end
  104.         SubspaceExplosion:Play()
  105.  
  106.         local e = Instance.new("Explosion")
  107.         e.BlastRadius = 16
  108.         e.BlastPressure = 1000000
  109.         e.Position = Mine.Position
  110.         e.Parent = Mine
  111.  
  112.         local creator = Mine:FindFirstChild("creator")
  113.  
  114.         e.Hit:connect(function(part, distance)  onPlayerBlownUp(part, distance, creator) end)
  115.  
  116.  
  117.         for i=0,1,.2 do
  118.             Mine.Transparency = i
  119.             wait(.05)
  120.         end
  121.         wait(4)
  122.         Mine:Remove()
  123.     end
  124.     local function update()
  125.         if (calibrated == false) then
  126.             if (Mine.Velocity.magnitude > .1) then
  127.                 cur_time = 0
  128.             end
  129.  
  130.             if (cur_time > calibration_time) then
  131.                 activateMine()
  132.             end
  133.         else
  134.             -- calibrated mine
  135.             if (math.random(1,20) == 2) then
  136.                 pulse()
  137.             end
  138.  
  139.             if (cur_time > max_life) then pulse() Mine:Remove() end
  140.         end
  141.     end
  142.     local function OnTouch(part)
  143.         if (calibrated == false) then
  144.             cur_time = 0
  145.         else
  146.             explode()
  147.         end
  148.     end
  149.  
  150.     connection = Mine.Touched:connect(OnTouch)
  151.  
  152.     while Mine and Mine.Parent do
  153.         update()
  154.         local e,g = wait(.5)
  155.         cur_time = cur_time + e
  156.     end
  157. end
  158.  
  159. function plant(pos)
  160.  
  161.  
  162.     local vCharacter = Tool.Parent
  163.     local vPlayer = game.Players:playerFromCharacter(vCharacter)
  164.  
  165.     local spawnPos = vCharacter.PrimaryPart.Position
  166.  
  167.  
  168.     local bomb = Tool.Handle:Clone()
  169.     bomb.CanCollide = true
  170.     bomb.Transparency = 0
  171.     bomb.Position = pos
  172.     bomb.Size = Vector3.new(2,2,2)
  173.     bomb.Name = "SubspaceTripmine"
  174.     bomb.Locked = true
  175.  
  176.  
  177.     local creator_tag = Instance.new("ObjectValue")
  178.     creator_tag.Value = vPlayer
  179.     creator_tag.Name = "creator"
  180.     creator_tag.Parent = bomb
  181.  
  182.     bomb.Parent = game.Workspace
  183.    
  184.     coroutine.wrap(function()
  185.         runmine(bomb)
  186.     end)()
  187. end
  188.  
  189.  
  190. Tool.Enabled = true
  191. function onActivated()
  192.     if not Tool.Enabled then
  193.         return
  194.     end
  195.  
  196.     Tool.Enabled = false
  197.  
  198.     local character = Tool.Parent;
  199.     local humanoid = character.Humanoid
  200.     if humanoid == nil then
  201.         print("Humanoid not found")
  202.         return
  203.     end
  204.  
  205.     local targetPos = humanoid.TargetPoint
  206.  
  207.     Tool.Handle.Transparency = 1
  208.     plant(Tool.Handle.Position)
  209.     --wait(3)
  210.     Tool.Handle.Transparency = 0
  211.  
  212.     Tool.Enabled = true
  213. end
  214.  
  215.  
  216. Tool.Activated:Connect(onActivated)
  217. Tool.Parent = owner:FindFirstChildOfClass("Backpack")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement