I found in my inventory day and night music script and paste in game:
while true do
if game.Lighting.ClockTime >= 6 and game.Lighting.ClockTime <= 18 then
game.Workspace.Sound.Atmosphere.Day:Play()
game.Workspace.Sound.Atmosphere.Night:Stop()
end
if game.Lighting.ClockTime >= 18 or game.Lighting.ClockTime <= 6 then
game.Workspace.Sound.Atmosphere.Day:Stop()
game.Workspace.Sound.Atmosphere.Night:Play()
end
wait(0.1)
end
Change the location of your sounds and call this using a local script in StarterGui, it should work.
local SoundService = game:GetService("SoundService")
while task.wait(1) do
local clockTime = game.Lighting.ClockTime
if clockTime >= 6 and clockTime < 18 then
SoundService.Atmosphere.Day:Play()
workspace.Sound.Atmosphere.Night:Stop() -- move to SoundService like the first
else
workspace.Atmosphere.Day:Stop() -- move to SoundService like the first
workspace.Sound.Atmosphere.Night:Play() -- move to SoundService like the first
end
end
The loop is the problem, it will keep playing again and again, this should fix your problem.
local SoundService = game:GetService("SoundService")
while true do
local clockTime = game.Lighting.ClockTime
if clockTime >= 6 and clockTime < 18 then
if not DaySound.IsPlaying then
DaySound:Play()
end
if NightSound.IsPlaying then
NightSound:Stop()
end
else
if DaySound.IsPlaying then
DaySound:Stop()
end
if not NightSound.IsPlaying then
NightSound:Play()
end
end
task.wait(1)
end