Lights (script.parent) will not turn off after clocktime 8 - 9, what did I do wrong and how can I fix it?
This is my script:
Is this the entire script? You’re going to have to constantly check to see if the ClockTime is set to greater than 8 or less than 9, rather than just checking a single time.
1 Like
It appears that your code is only running once right now, you could try to either wrap it all in a loop or connect it to a OnPropertyChangedSignal event for the ClockTime. e.g:
-- solution #1
while true do
task.wait(60) -- time is adjustable
-- your code here
end
or
-- solution #2
game.Lighting:OnPropertyChangedSignal('ClockTime'):Connect(function()
-- your code here
end)
Do take notes that solution #2 might not be as efficient (as is) as solution #1
1 Like
Works, forgot I needed a loop.
1 Like
local lighting = game:GetService("Lighting")
lighting.LightingChanged:Connect(function(skyChanged)
--Do code.
end)
You can also utilise the less frequently used RBXScriptSignal object (event) named “LightingChanged”.
https://developer.roblox.com/en-us/api-reference/event/Lighting/LightingChanged
1 Like