I tried this, but the counter breaks when reaching the number I have put for the music.
local StartTime = 1610294400
local StartMusic = 1610294100
local TweenService = game:GetService("TweenService")
while true do
local currentTime = os.time()
local timeLeft = StartTime - currentTime
local mFloor = math.floor
local DaysLeft = mFloor((timeLeft / 60 / 60 / 24) % (365 + 0.2425))
local HoursLeft = mFloor((timeLeft / 60 / 60) % 24)
local MinutesLeft = mFloor((timeLeft / 60) % 60)
local SecondsLeft = mFloor(timeLeft % 60)
if currentTime >= StartMusic then
script.parent.Music:Play()
wait(273)
Script.Parent.Music:Stop()
end
if currentTime >= StartTime then
-- Whatever is inside here is what happens when the countdown hits 0! --
local dec = script.Parent.BillboardGui:GetDescendants()
for i,v in pairs(dec) do
if v.ClassName == "TextLabel" then
TweenService:Create(v,TweenInfo.new(2,Enum.EasingStyle.Linear),{TextTransparency = 1}):Play()
TweenService:Create(v,TweenInfo.new(2,Enum.EasingStyle.Linear),{TextStrokeTransparency = 1}):Play()
end
end
break
else
I have put it like this, but the music plays again every 1 second.
local StartTime = 1610294400
local StartMusic = 1610294100
local TweenService = game:GetService("TweenService")
while true do
local currentTime = os.time()
local timeLeft = StartTime - currentTime
local mFloor = math.floor
local DaysLeft = mFloor((timeLeft / 60 / 60 / 24) % (365 + 0.2425))
local HoursLeft = mFloor((timeLeft / 60 / 60) % 24)
local MinutesLeft = mFloor((timeLeft / 60) % 60)
local SecondsLeft = mFloor(timeLeft % 60)
if currentTime >= StartMusic then
script.parent.Music:Play()
end
if currentTime >= StartTime then
-- Whatever is inside here is what happens when the countdown hits 0! --
local dec = script.Parent.BillboardGui:GetDescendants()
for i,v in pairs(dec) do
if v.ClassName == "TextLabel" then
TweenService:Create(v,
Hey, this is a great tutorial. I was just wondering is there any possible way without a StartTime? If i only have a StopTime would it also work out?
Right now it is broken at
local secondsleft = EventStop - CurrentTime
It prints this out: Days: 4 Hours: inf Minutes: 47 - Server
local EventStop = 1652546204 -- Epoch Time
while wait(1) do
local CurrentTime = os.time()
if CurrentTime >= EventStop then -- If the current time is greater then the eventstop it would break the entire loop
break
end
if CurrentTime <= EventStop then -- If the current time is under the eventstop it will continue
local secondsleft = EventStop - CurrentTime
local days = math.floor(secondsleft % (60*60*24*30) / (60*60*24))
local hours = math.floor(secondsleft % (60*60*24) / (60*0))
local minutes = math.floor(secondsleft % (60*60) / 60)
Event_Time.Value = "Days: " .. days .. " Hours: " .. hours .. " Minutes: " .. minutes
print("Days: " .. days .. " Hours: " .. hours .. " Minutes: " .. minutes)
end
end