local TimeToStop = 1591938000
function liveEvent()
local bodyForce = Instance.new("BodyForce")
bodyForce.Force = Vector3.new(0,10000,0)
bodyForce.Parent = game.Workspace.Rocket
wait(8)
bodyForce.Force = Vector3.new(-769.718, 1143.301, 240.556)
game.Workspace.Rocket.Anchored = false
game.Workspace.Rocket.MeshPart.Flames.ParticleEmitter.Enabled = true
end
while wait(1) do
local timeNow = os.time()
if timeNow >= TimeToStop then
break
end
if timeNow >= TimeToStart then
print("Starting live event !")
liveEvent()
break
else
workspace.EventLiveInfo.SurfaceGui.TextLabel.Text = "Time to Live Event Days:"..(TimeToStart-timeNow/60/60/60).."Hours:"..(TimeToStart-timeNow/60/60).."Minutes:"..(TimeToStart-timeNow/60).."Seconds:"..(TimeToStart-timeNow)
end
end
Ok, so from what I read, you need a timer in days, hours, minutes, and seconds right? If so, then it needs to be relative. You need to get the amount of time from now to the live event time.
local timeLeft = TimeToStop - os.time() --amount of seconds
Then, you can turn that into readable time. It’s not that easy to use a bunch of for loops for that, so you can do it with each individual seconds amount. I actually made a module for this, so all you have to do using that module is:
for i = timeLeft, 0, -1 do
tfm:Convert(i) --for example 32:12:02
end
Yes it is but you messed something . I meant make event timer that shows time in days hours minutes and seconds before live show event . The main code starts from here
That’s a code of text that will show the time that playerse need to wait before event . And I don’t know how to make it in Days , hours , minutes , seconds . Anyways thabk you for answer !
For showing it as hours, just divide by 3.600 and modulus by 24. math.floor((TimeToStart-timeNow) / 3600) % 24, so it won’t show values over 24, etc.
Oh, it’s in the BIDMAS order so TimeToStart-timeNow/60/60/60 is actually doing TimeToStart-(((timeNow/60)/60)/60).
Something like this
local days = math.floor((TimeToStart - timeNow) / 86400); -- 86.400 seconds in a day
local hours = math.floor((TimeToStart - timeNow) / 3600) % 24; -- 3.600 in an hour
local minutes = math.floor((TimeToStart - timeNow) / 60) % 60; -- 60 seconds in a minute
local seconds = (TimeStart - timeNow) % 60;
Maybe run the function everytime the value updated? Something like this:
local function divmod()
return math.floor(a / b), a % b
end;
local days = TimeToStart - timeNow;
local hours, minutes, seconds;
days, seconds = divmod(days, 60);
days, minutes = divmod(days, 60);
days, hours = divmod(days, 60);
workspace.EventLiveInfo.SurfaceGui.TextLabel.Text = "Time to Live Event:"..days..":"..hours..":"..minutes..":"..seconds;
You can use string.format to seperate each one into hours, minutes, and seconds:
local TimeToStop = 86400 --Amount of seconds in one day
function Format(Int)
return string.format("%02i", Int)
end
function convertToHMS(Seconds)
local Minutes = (Seconds - Seconds%60)/60
Seconds = Seconds - Minutes*60
local Hours = (Minutes - Minutes%60)/60
Minutes = Minutes - Hours*60
return Format(Hours)..":".. Format(Minutes)..":"..Format(Seconds)
end
print(convertToHMS(TimeToStop)) --Prints 24:00:00
workspace.EventLiveInfo.SurfaceGui.TextLabel.Text = "Time to live event ("..convertToHMS(TimeToStop)..")"