Hey everyone! So im trying to find a day and night cycle script in the toolbox script but none of them work so this is my only option for the script. If you have the script please tell me on where to put it so I dont have to be confused on where to place it. Anyway thank you and have a nice day.
7 Likes
You can insert a Script into ServerScriptService that is used for a day/night system using the Lighting Service.
Inside script:
local Lighting = game:GetService("Lighting")
local Minutes = 7 * 60
while task.wait() do
Lighting:SetMinutesAfterMidnight(Minutes)
Minutes = Lighting:GetMinutesAfterMidnight()
if Minutes > 19 * 60 then
Minutes = Minutes + 3
elseif Minutes > 7 * 60 then
Minutes = Minutes + 1
else
Minutes = Minutes + 3
end
end
You can adjust the script around to suit your game.
11 Likes
Thanks for the help Austin! Your a great helping hand for me. Also a few Questions, Does the line “local Minutes = 7 * 60” mean you have to put the seconds and minutes or am I getting it confused and maybe explain it thoroughly so I that I can understand and do the changes correctly, Thanks.
3 Likes
The variable sets the minutes 7 hours after midnight
4 Likes
local Game = game
local Lighting = Game:GetService("Lighting")
local RunService = Game:GetService("RunService")
local MinutesPerSecond = 1 --1 second equivalent to 1 minute (1 day = 24 minutes).
local function OnHeartbeat(Delta)
Lighting.ClockTime += (MinutesPerSecond / 60) * Delta
end
RunService.Heartbeat:Connect(OnHeartbeat)
15 Likes
Âżwhy not use?
local Lighting = game:GetService(“Lighting”)
while true do
Lighting.ClockTime = Lighting.ClockTime +0.1
wait(1)
end
4 Likes