Hello, so as the title explains, the PointLight is not disabling at a certain time of day. I would like to know if my script is wrong, outdated e.t.c.
Below is code
while true do
if game.Lighting.TimeOfDay <= "19:00:00" then
script.Parent.PointLight.Enabled = true
elseif
game.Lighting.TimeOfDay >= "6:20:00" then
script.Parent.PointLight.Enabled = false
end
end
There are no errors in the output.
Any help would be great!
There must be an error with this code, since there is no wait statement preventing an execution exhaustion.
Also, the code is erroring because you cannot compare strings.
1 Like
even if the script works it does it in a terrible way, if it checks every single tick then it will be really laggy
1 Like
i have a working script from a solar powered light i made that does the same thing pretty much i’ll show it to you
-- This script uses the "ClockTime" property located in Lighting.
while wait(1) do
if game.Lighting.ClockTime >= 6.5 then
script.Parent.PointLight.Enabled = false
script.Parent.BrickColor = BrickColor.new("Institutional white")
else
script.Parent.PointLight.Enabled = true
script.Parent.BrickColor = BrickColor.new("Cool yellow")
end
if game.Lighting.ClockTime >= 18 then
script.Parent.PointLight.Enabled = true
script.Parent.BrickColor = BrickColor.new("Cool yellow")
end
end
1 Like
To add on to this you can add an or statement and also you can change the material to neon in certain scenarios.
oh thats a good idea i’ll make another script that makes it neon. 1 sec
It’s still very bad to use a while loop I suggest using GetPropertyChagnedSignal() and maybe use a dictionary instead.
1 Like
Apperently this has worked. The only thing is I don’t understand the diffrence between ClockTime and TimeOfDay (or if there is a diffrence)
yeah but this is a quick script that works and while its not optimized very well it does the job
time of day is a string and clocktime is a normal varible so its easier to use
1 Like