Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

"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

Log in to vote
0
Answered by 8 years ago
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

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! officialflufybrik 0 — 8y
Ad
Log in to vote
-1
Answered by
theCJarmy7 1293 Moderation Voter
8 years ago

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
0
Output: ServerScriptService.DayNightScript:11: '<eof>' expected near 'end' officialflufybrik 0 — 8y
0
theres a extra end CybeTech 37 — 8y
0
Just noticed time is actually changing but the skybox makes it look like night! Great, another problem (not your fault though!). officialflufybrik 0 — 8y
0
you only asked to fix the loop, so thats what i did. i assumed after that the problem would be fixed. guess not. theCJarmy7 1293 — 8y

Answer this question