How do I make different music play at daytime and nighttime correctly?
So I have two Background Music files in the workspace called "SurfaceDay" and "SurfaceNight."
I use this script down below.
01 | minutesAfterMidnight = 0 |
04 | minutesAfterMidnight = minutesAfterMidnight + 10 |
05 | game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) |
08 | if game.Lighting:GetMinutesAfterMidnight() > 6 * 60 and minutesAfterMidnight < 17 * 59 then |
09 | if game.Workspace.SurfaceDay.IsPaused then |
10 | game.Workspace.SurfaceNight:Stop() |
11 | game.Workspace.SurfaceDay:Play() |
14 | if game.Lighting:GetMinutesAfterMidnight() > 18 * 00 and minutesAfterMidnight < 6 * 59 then |
15 | if game.Workspace.SurfaceNight.IsPaused then |
16 | game.Workspace.SurfaceDay:Stop() |
17 | game.Workspace.SurfaceNight:Play() |
The problem here is that if the time was nighttime, the Night music only plays once when I set it to loop, and if the time was daytime, the Day music played but the Night music never plays. Is there a reason for this problem and how do I fix this?
Thank you.