local timeVar = game.Lighting.TimeOfDay if timeVar >= "7:30:00" then script.Dawn.Play() script.Sunset.Stop() elseif timeVar >= "20:00:00" then script.Sunset.Play() script.Dawn.Stop() end
The songs don't play at all with no error, so it must mean they didn't even trigger?
Dawn & Sunset are two sounds within the script that is written on.
Thanks
You could also use: local minutes_after_midnight = game:GetService("LightingService"):GetMinutesAfterMidnight()
You can't compare string values with greater than or equal to, because they're strings, not numbers. You can, however, convert the strings to numbers and compare them.
Finished Script
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 script.Dawn.Play() script.Sunset.Stop() elseif t >= 200000 then script.Sunset.Play() script.Dawn.Stop() end
Use tonumber()
First of all, pretty much like aqua said, you can't compare it to string.
But the tonumber() will change your string into actual numbers.
Let me show you an example of tonumber(), along with chatted event (I kind of like chatted event :D)
Number = 123 game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(msg) if msg == "123" then msg = tonumber(Number) end
I'm pretty sure this is a working example