i want to create a Prison Curfew System with diffrent events at specific times, like for an example if the time was 11:30 then it would be Freetime and 14:50 be like Lunch or something like that…
Be able to create events or fire a function on a specific time.
What is the issue? Include screenshots / videos if possible!
The issue is that i have no clue how i would achieve this kind of system, i know it will be a While true loop but unsure how to start.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I think the way of doing this is by using the Clocktime in the Lighting, creating a Day/Night cycle and when a specific Clocktime hits then fire an event. I do not see anyone else asking about this on here…
It sounds easy to make but i am still not that good at coding so i want to ask here incase anyone might have a solution or a way i could get started with this.
local minspersec = 10 -- how many in game minutes pass every irl second
local lighting = game:GetService("Lighting")
local starttime = 9
local curfewtime = 10.5 -- 10.5 would be 10:30 because the 10 is the hour and .5 is how much of the next hour has passed, so half, therefore 30 mins
local endcurfew = 11
lighting.ClockTime = starttime
while true do
task.wait(1)
lighting.ClockTime = lighting.ClockTime + (minspersec/60)
local hour = math.floor(lighting.ClockTime)
local min = math.floor((lighting.ClockTime - hour) * 60)
print("the time is: "..tostring(hour)..":"..tostring(min))
if lighting.ClockTime == curfewtime then
print("wow curfew time")
-- code to do on curfew here
elseif lighting.ClockTime == endcurfew then
print("end of curfew")
-- code to do on end of curfew
end
end