Advertisement
bobopopcornboy

Trip mine

Sep 4th, 2024
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.08 KB | None | 0 0
  1. Mine = Instance.new("Part")
  2. Mine.Parent = workspace
  3. Mine.Position = Vector3.new(0,5,0)
  4.  
  5. Mesh = Instance.new("SpecialMesh")
  6. Mesh.Parent = Mine
  7. Mesh.MeshId = "http://www.roblox.com/asset/?id=11954776"
  8. Mesh.TextureId = "http://www.roblox.com/asset/?id=11954766"
  9. Mesh.Scale = Vector3.new(0.7,0.7,0.7)
  10.  
  11. DunDun = Instance.new("Sound")
  12. DunDun.SoundId = "http://www.roblox.com/asset/?id=11984254"
  13. DunDun.Parent = Mine
  14.  
  15. SubspaceExplosion = Instance.new("Sound")
  16. SubspaceExplosion.SoundId = "http://www.roblox.com/asset/?id=11984351"
  17. SubspaceExplosion.Parent = Mine
  18.  
  19. Calibrate = Instance.new("Sound")
  20. Calibrate.SoundId = "http://www.roblox.com/asset/?id=11956590"
  21. Calibrate.Looped = true
  22. Calibrate.Parent = Mine
  23. Calibrate:Play()
  24.  
  25. local calibration_time = 2 -- needs to be still/untouched for this long before calibrating
  26. local cur_time = 0
  27. local max_life = 120 -- these things last for 2 minutes on their own, once activated
  28. local calibrated = false
  29.  
  30. local connection = nil
  31.  
  32. function activateMine()
  33.     for i=0,1,.1 do
  34.         Mine.Transparency = i
  35.         wait(.05)
  36.     end
  37.     calibrated = true
  38.     Calibrate:Stop()
  39. end
  40.  
  41. function pulse()
  42.     DunDun:Play()
  43.  
  44.     for i=.9,.5,-.1 do
  45.         Mine.Transparency = i
  46.         wait(.05)
  47.     end
  48.  
  49.     for i=.5,1,.1 do
  50.         Mine.Transparency = i
  51.         wait(.05)
  52.     end
  53. end
  54.  
  55. function explode()
  56.     connection:disconnect()
  57.  
  58.     for i=1,0,-.2 do
  59.         Mine.Transparency = i
  60.         wait(.05)
  61.     end
  62.     SubspaceExplosion:Play()
  63.  
  64.     local e = Instance.new("Explosion")
  65.     e.BlastRadius = 16
  66.     e.BlastPressure = 1000000
  67.     e.Position = Mine.Position
  68.     e.Parent = Mine
  69.  
  70.     local creator = script.Parent:findFirstChild("creator")
  71.  
  72.     e.Hit:connect(function(part, distance)  onPlayerBlownUp(part, distance, creator) end)
  73.  
  74.  
  75.     for i=0,1,.2 do
  76.         Mine.Transparency = i
  77.         wait(.05)
  78.     end
  79.     wait(4)
  80.     Mine:Remove()
  81. end
  82.  
  83. function update()
  84.     if (calibrated == false) then
  85.         if (Mine.Velocity.magnitude > .05) then
  86.             cur_time = 0
  87.         end
  88.  
  89.         if (cur_time > calibration_time) then
  90.             activateMine()
  91.         end
  92.     else
  93.         -- calibrated mine
  94.         if (math.random(1,20) == 2) then
  95.             pulse()
  96.         end
  97.  
  98.         if (cur_time > max_life) then pulse() Mine:Remove() end
  99.     end
  100. end
  101.  
  102.  
  103. function OnTouch(part)
  104.     if (calibrated == false) then
  105.         cur_time = 0
  106.     else
  107.         explode()
  108.     end
  109. end
  110.  
  111.  
  112. function onPlayerBlownUp(part, distance, creator)
  113.  
  114.     if (part:getMass() < 300) then
  115.         part.BrickColor = BrickColor.new(1032)
  116.         local s = Instance.new("Sparkles")
  117.         s.Parent = part
  118.         game.Debris:AddItem(s, 5)
  119.     end
  120.    
  121.  
  122.     if creator ~= nil and part.Name == "Head" then
  123.         local humanoid = part.Parent.Humanoid
  124.         tagHumanoid(humanoid, creator)
  125.     end
  126. end
  127.  
  128. function tagHumanoid(humanoid, creator)
  129.     -- tag does not need to expire iff all explosions lethal
  130.    
  131.     if creator ~= nil then
  132.         local new_tag = creator:clone()
  133.         new_tag.Parent = humanoid
  134.     end
  135. end
  136.  
  137. function untagHumanoid(humanoid)
  138.     if humanoid ~= nil then
  139.         local tag = humanoid:findFirstChild("creator")
  140.         if tag ~= nil then
  141.             tag.Parent = nil
  142.         end
  143.     end
  144. end
  145.  
  146. connection = Mine.Touched:connect(OnTouch)
  147.  
  148.  
  149. while true do
  150.     update()
  151.     local e,g = wait(.5)
  152.     cur_time = cur_time + e
  153. end
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
Tags: Roblox gear
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement