Advertisement
HowToRoblox

BombHandler

Sep 27th, 2020
1,596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. local bomb = script.Parent
  2.  
  3. local timeLabel = bomb.Timer.TimerGui.Time
  4. local buttonClickDetector = bomb.Button.ClickDetector
  5.  
  6.  
  7. local timeToExplode = 10
  8.  
  9. local timerActive = false
  10.  
  11.  
  12. buttonClickDetector.MouseClick:Connect(function()
  13.    
  14.     timerActive = not timerActive
  15.    
  16.     if timerActive then
  17.        
  18.        
  19.         repeat 
  20.             wait(1)
  21.            
  22.             timeToExplode = timeToExplode - 1
  23.            
  24.            
  25.             local secs = timeToExplode % 60
  26.             local mins = math.floor(timeToExplode / 60) % 60
  27.             local hours = math.floor(timeToExplode / (60 * 60))
  28.            
  29.             if string.len(secs) < 2 then secs = "0" .. secs end
  30.             if string.len(mins) < 2 then mins = "0" .. mins end
  31.             if string.len(hours) < 2 then hours = "0" .. hours end
  32.            
  33.            
  34.             local formattedTime = hours .. ":" .. mins .. ":" .. secs
  35.            
  36.            
  37.             timeLabel.Text = formattedTime
  38.            
  39.            
  40.         until timeToExplode == 0 or not timerActive
  41.        
  42.        
  43.         if timeToExplode == 0 then
  44.            
  45.             local explosion = Instance.new("Explosion")
  46.             explosion.Position = bomb.Timer.Position
  47.             explosion.Parent = workspace
  48.            
  49.             bomb:Destroy() 
  50.         end
  51.     end
  52. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement