Exactly what the title says; I want to create a timer that runs every 24 hours (every 12 AM EST.) I’ve seen posts about using os.time, but I don’t know how to make that repeatedly run every 24 hours and in my script.
My CURRENT timer script (local script at the moment, could change it if necessary):
local RunService = game:GetService("RunService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage.TimerEnded
local event2 = replicatedStorage.TimerEnded2
local timer_bind = "Timer"
local Player = game.Players.LocalPlayer
repeat wait() until Player:FindFirstChild("Data")
local Data = Player.Data
local value = Data.JobTimerRemaining
local label = script.Parent
local RandomJob = math.random(1, 4)
local RandomJob2 = math.random(1, 4)
wait(3)
while true do
local function timer(timeRemaining)
local delayEvent = Instance.new("BindableEvent")
RunService:BindToRenderStep(timer_bind, Enum.RenderPriority.Last.Value - 1, function(delta)
local hours = math.floor(timeRemaining / 3600)
local minutes = math.floor(timeRemaining / 1440)
local seconds = math.floor(timeRemaining % 60)
timeRemaining -= delta
value.Value = timeRemaining
label.Text = "Daily Job - Next Job In "..string.format("%02i:%02i:%02i", hours, minutes, seconds)
if timeRemaining <= 0 then
delayEvent:Fire()
RunService:UnbindFromRenderStep(timer_bind)
end
end)
delayEvent.Event:Wait()
end
timer(value.Value)
event:Fire(RandomJob)
event2:Fire(RandomJob2)
end
TL;DR: Change this above code to have 2 remote events fire every 12 AM EST