local time = game.Lighting.TimeOfDay local t = tonumber(string.sub(time,1,2)..string.sub(time,4,5)..string.sub(time,7,8)) --convert time to a number if t >= 73000 then for i = .2,0,-.001 do --loop that turns music down over 2 seconds wait(.01) script.Sunset.Volume = i if i == 0 then script.Sunset:Stop() break --is this necessary? end end script.Dawn:Play() elseif t >= 200000 then for i = .2,0,-.001 do --same for this ! wait(.01) script.Dawn.Volume = i if i == 0 then script.Dawn:Stop() break end end script.Sunset:Play() end
I tried this on a multiplayer server, and the song for Dawn wouldn't tone down to 0 volume when the time came along. Any ideas?
ps: Huge thanks to the other guy that suggested I turned the strings into numbers so I could compare them using tonumber.
While I'm trying to figure it out, here's what I made from scratch.
local time = game.Lighting.TimeOfDay local t = tonumber(string.sub(time,1,2)..string.sub(time,4,5)..string.sub(time,7,8)) --convert time to a number if t >= 73000 and t < 200000 then for i = .2,0,-.001 do wait() script.Sunset.Volume = i end script.Sunset:Stop() script.Sunset.Volume = .2 script.Dawn:Play() elseif t >= 200000 then for i = .2,0,-.001 do wait() script.Dawn.Volume = i end script.Dawn:Stop() script.Dawn.Volume = .2 script.Sunset:Play() end