Advertisement
HowToRoblox

CountdownScript

Dec 15th, 2021
2,165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. local newYear = os.time({year = os.date("%Y", os.time() + (365*24*60*60) - (24*60*60)), month = 1, day = 1})
  2.  
  3.  
  4. while wait(1) do
  5.    
  6.     local currentTime = os.time()
  7.    
  8.     local timeDiff = newYear - currentTime
  9.    
  10.    
  11.     local d = math.floor(timeDiff/60/60/24)
  12.     local h = string.format("%0.2i", math.floor((timeDiff - (d*60*60*24))/60/60))
  13.     local m = string.format("%0.2i", math.floor((timeDiff - (d*60*60*24) - (h*60*60))/60))
  14.     local s = string.format("%0.2i", timeDiff - (d*60*60*24) - (h*60*60) - (m*60))
  15.     local formattedTime = d .. ":" .. h .. ":" .. m .. ":" .. s
  16.    
  17.     script.Parent.Clock.ClockGui.TimeToNewYear.Text = timeDiff <= 0 and "00:00:00:00" or formattedTime
  18.    
  19.     if timeDiff <= 0 then
  20.  
  21.         break
  22.     end
  23. end
  24.  
  25.  
  26. for i = 1, 100 do
  27.    
  28.     for x = 1, math.random(2, 7) do
  29.        
  30.         spawn(function()
  31.            
  32.             local firework = script.Firework:Clone()
  33.             firework.Parent = workspace
  34.            
  35.             local cf = CFrame.new(
  36.                 Vector3.new(
  37.                     math.random(script.Parent.FireworkSpawn.Position.X - script.Parent.FireworkSpawn.Size.X/2, script.Parent.FireworkSpawn.Position.X + script.Parent.FireworkSpawn.Size.X/2),
  38.                     script.Parent.FireworkSpawn.Position.Y + firework.Size.Y/2,
  39.                     math.random(script.Parent.FireworkSpawn.Position.Z - script.Parent.FireworkSpawn.Size.Z/2, script.Parent.FireworkSpawn.Position.Z + script.Parent.FireworkSpawn.Size.Z/2)),
  40.                 Vector3.new(
  41.                     0,
  42.                     math.random(0, 360),
  43.                     0))
  44.            
  45.             firework.CFrame = cf
  46.            
  47.             firework.Transparency = 0
  48.            
  49.             firework.Velocity = Vector3.new(0, 200, 0)
  50.            
  51.             firework.Anchored = false
  52.            
  53.             firework.LaunchSound:Play()
  54.            
  55.             repeat wait() until firework.Velocity.Magnitude <= 30
  56.            
  57.             firework.Anchored = true
  58.             firework.Transparency = 1
  59.            
  60.             firework.FireworkParticles.Enabled = true
  61.            
  62.             firework.ExplodeSound:Play()
  63.            
  64.             game:GetService("Debris"):AddItem(firework, 2)
  65.         end)
  66.        
  67.         wait(math.random(10)/10)
  68.     end
  69.    
  70.     wait(math.random(1, 3))
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement