function onTouched() game.Lighting.TimeOfDay= "5:00:00" while game.Lighting.TimeOfDay<tonumber("6:00:00") do repeat game.Lighting.TimeOfDay = game.Lighting.TimeOfDay + "0:01:00" wait(.1) until game.Lighting.TimeOfDay > "6:00:00" end end script.Parent.Touched:connect(onTouched)
****new to scripting !**** current error : attempt to compare string with nil
I've fixed several errors such as above but script doesn't run, I know the issue with it. Is there anyway I can get around this? Do I need to take a different approach?
Not sure where to start D:
Trying to compare TimeOfDay might be confusing it, given it has colons. Try instead to use Lighting.Clocktime. Also, you have two loops (a while and repeat) doing the same thing, so you can just remove one of them.
local function onTouched() game.Lighting.ClockTime = 5 while game.Lighting.ClockTime < 6 do game.Lighting.ClockTime = game.Lighting.ClockTime + 0.01 wait(0.1) end end script.Parent.Touched:connect(onTouched)