Hello! So, I've been working on a place with a friend, and we're trying to make a ceiling light that turns off at night indicating that the store is closed, but turns on when it's day indicating that the store is open. There's no errors in the output, it just does nothing. Here's my current attempt at the script:
while wait(1) do if game.Lighting.ClockTime == 0 then script.Parent.PointLight.Enabled = false script.Parent.BrickColor = BrickColor.new("Really black") else script.Parent.PointLight.Enabled = true script.Parent.BrickColor = BrickColor.new("Institutional white") end end
Any answer that actually works is fine.
(It's a workspace script inside of the light part)
Assuming you have a script that is progressing the ClockTime of the game, here is what needs to be done. The issue was that your code is running on a loop that might not pick up when time = 0
due to the wait(1)
and how quickly the ClockTime
is actually ticking.
First, you can use Changed
to run a function when any property of Lighting
changes.
game.Lighting.Changed:Connect(function(changedProperty) --Lighting property is changed if changedProperty == "ClockTime" then --If ClockTime is changed, then run if game.Lighting.ClockTime == 0 then --Turn off light when ClockTime == 0 script.Parent.PointLight.Enabled = false script.Parent.BrickColor = BrickColor.new("Really black") else --Turn on light if ClockTime ~= 0 script.Parent.PointLight.Enabled = true script.Parent.BrickColor = BrickColor.new("Institutional white") end end end)