Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Anyone know how to create a day/night cycle, but only stays night?

I've been attempting this for a while. I am making a rather "spooky" game and am trying to make a storyline to where you are in a land where the sky is "cursed" and is always night time. So basically, I've got the code somewhat set up, I'm just trying to find the right number for the minutesAfterMidnight command.

local timeOfDay = minutesAfterMidnight
minutesAfterMidnight = 1439
print("variable works") --just for debugging
while true do
	minutesAfterMidnight = minutesAfterMidnight + 1
	game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
	timeOfDay = minutesAfterMidnight
	wait(.1)
	print("time of day works") --also for debugging
	if timeOfDay < 361 and timeOfDay > 359 then
		minutesAfterMidnight = 1439
	end
	print("if statement works") --once again for debugging
end

Again, if someone could either help me with the code and/or find the right number for the time of day, that would be awesome.

2 answers

✓ Accepted answer

So basically, what you want is you want to cycle through nightime, but instead of going into daytime, you want to continue cycling through nighttime?

I would accomplish this by adding something like this to your script:

local maxTime = --Set this to whatever you decide, whatever value minutesAfterMidnight is when you stop.
local minTime = --Set this to be the beginning time of your night cycle

while true do --Add this to the existing while loop instead of creating another
print(minutesAfterMidnight) --Run the script and find when you want the cycle to stop, this should give you the exact time you want.  Use this to find the value for maxTime on your own.
do

And then basically what I would do after that is once you reach the maximum time you want, start subtracting from minutesAfterMidnight instead of adding. Then when you reach the minimum, start adding. And repeat.

2 comments

0

Sorry for the late response. But anyways, thanks a bundle. And yea, I was wanting it to cycle through like normal, except when the moon goes down, and when the sun usually would come up, the moon does instead.

0

Let me know if you need any additional help with this; my answer assumed you had enough knowledge to do it yourself once told how, but if you need help, I can help.

you dont need a code to always have night time, u can just set the time in lighting

This discussion is preserved as it was. New answers, comments, and votes are closed.