Indicate one day in ROBLOX

I’m making a day night system, for every day it shows a GUI of what day it is. I tried using * and a value but it was too fast and like in 2 minutes, it was already Day 10. Can someone show an example or something like that?

Wait, you want to make the day/night change move slower?

Also wdym * and a value?

Like I’m making a day night system. But, how do I indicate every day?

I used a value for every day but that didn’t work.

You could just slow down the value. Instead of doing VALUE * ORIGINAL NUMBER, you could do something like VALUE * (ORIGINAL NUMBER / 20).

Well, why not just make variables for every day of the week, and set the variable of the day to true when that day starts?

Sorry, I still don’t really get your question. Wdym “Indicate every day” ?

1 Like

Like if 1 day in roblox passes, the value goes up once.

As in, in game, in real life, or something else?

As in game. Using :SetMinutesAfterMidnight

In your loop to increment the time, you can have a conditional statement to check if minutes after midnight [mod] 24*60 is 0. If it is, increment the day variable.

1 Like

That’s easy, just make a variable that represents the day number, and add one to it whenever the day passes. Like this:

Variable = Variable + 1

Can you show me your day/night script?

It’s just a loop using while and :SetMinutesAfterMidnight

So,

while true do
wait(.1)
game:GetService("Lighting"):SetMinutesAfterMidnight()
end

Like that. Didn’t do the full script.

I never learnt about that method, but you can just do this:

Day = 1
while true do

-- At the end of the loop put this
Day = Day + 1
end

Like @RoxaneAurore said.

1 Like

So for example, you can have something like this.

local day = 1
while true do
	minutesAfterMidnight = minutesAfterMidnight + 1
	game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)

	if minutesAfterMidnight%(24*60) == 0
		 day = day + 1
	end

	wait(.1)
end

Each time the time increments, it checks if it’s midnight. If it is, it would increment the day variable.

2 Likes

The others have practically said what to do above; You can also try increasing the wait so it waits longer.

I tested it more and I realized that it increases in the middle of the night. How can I make it increase when the sun is out?

You might want to see this post, which might help you:

Tell me if you are not understanding.

So what I put above increments the day variable right at midnight when the minutes after midnight equals zero. If you wish to increment the day variable at another time, simply set the conditional statement to check if the operation equals the time you want (minutes after midnight).

Increments at midnight

if minutesAfterMidnight%(24*60) == 0 --0*60
		 day = day + 1
end

Increments one hour after midnight

if minutesAfterMidnight%(24*60) == 60 --1*60
		 day = day + 1
end

Increments two hours after midnight

if minutesAfterMidnight%(24*60) == 120 --2*60
		 day = day + 1
end

You need to make sure that it is actually possible for the time to be set to whichever time you use. For example, if your loop increments the time by one hour each time (assuming you start from 00:00), it wouldn’t be possible for the time to be set to anything not on the hour (e.g., 2:30, 1:12, 3:23).

Ohhh, yes I see. Thanks, again!