How would I make a sleep on force script?

So basically, I am making a day system, and you sleep at forced times. Let me explain, so basically at day, it doesn’t do anything, but at night, it forces you to sleep and plays an animation, and after 3 seconds, it is daytime. Can someone explain how I would do this?

Thanks, Vaelkarr.

changed the value of “ClockTime” in Lighting
Example:
local TimeToSleep = 18 ---- Hours of night
local StartTimeOfDay = 6.5 — Hours to start Day

------ function ------
if game.Lighting.ClockTime >= TimeToSleep then
---- Code to sleep or something ---
wait (3) --sleep time
--Agree code-
game.Lighting.ClockTime = StartTimeOfDay
end
------- end -----
4 Likes