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

How do I get my Day/Night script to not turn to night quickly and have it to repeat?

"QUICK, GET AN LUAMBULANCE!" (ha ha ha. get it?)

I am in the middle of making an Day/Night script and this is how it went.

if true do
	game.Lighting:SetMinutesAfterMidnight(12 * 1)
	wait(1)
	game.Lighting:SetMinutesAfterMidnight(18 * 1)
	wait(1)
	game.Lighting:SetMinutesAfterMidnight(00 * 1)
	wait(1)
	game.Lighting:SetMinutesAfterMidnight(6 * 1)
	wait(1)
end

Whenever I run/test the game it would say the following:

ServerScriptService.DayNightScript:1: 'then' expected near 'do'

So I followed the instructions and made the changes to the script and this is what i got.

if true then do
	game.Lighting:SetMinutesAfterMidnight(12 * 1)
	wait(1)
	game.Lighting:SetMinutesAfterMidnight(18 * 1)
	wait(1)
	game.Lighting:SetMinutesAfterMidnight(00 * 1)
	wait(1)
	game.Lighting:SetMinutesAfterMidnight(6 * 1)
	wait(1)
end
end

Now when i run the game this time, the script changed the day to night as soon as i started and it won't repeat itself. It's kinda weird so please help me. I'm just starting out as a scripter. Thanks in advance. I want to be original as possible!

Peace!

2 answers

while true do
    game.Lighting:SetMinutesAfterMidnight(12 * 1)
    wait(5)
    game.Lighting:SetMinutesAfterMidnight(18 * 1)
    wait(5)
    game.Lighting:SetMinutesAfterMidnight(00 * 1)
    wait(5)
    game.Lighting:SetMinutesAfterMidnight(6 * 1)
    wait(5)
end

This may work

1 comment

0

New Problem: The Skybox/sky is forever night but time is still changing (for some odd reason). Please help me! Thanks in advance bros!

try

while true do
    game.Lighting:SetMinutesAfterMidnight(12 * 1)
    wait(1)
    game.Lighting:SetMinutesAfterMidnight(18 * 1)
    wait(1)
    game.Lighting:SetMinutesAfterMidnight(00 * 1)
    wait(1)
    game.Lighting:SetMinutesAfterMidnight(6 * 1)
    wait(1)
end
end

4 comments

0

Output: ServerScriptService.DayNightScript:11: '' expected near 'end'

0

theres a extra end

0

Just noticed time is actually changing but the skybox makes it look like night! Great, another problem (not your fault though!).

0

you only asked to fix the loop, so thats what i did. i assumed after that the problem would be fixed. guess not.

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