hello, so, again, im trying to make a game that where if its day a street light turns off but when its night it turns on, it works when i only change the time in explorer then hit play. can i get help?
if game.Lighting.TimeOfDay = 0 then game.Workspace.lightfolder.streetlamp1.PointLight.Enabled = true else game.Workspace.lightfolder.streetlamp1.PointLight.Enabled = false end
Hello, Pencil_Supply. I see that you are struggling to make a working streetlight script. Don't worry, I have you covered. Use this script here:
game.Lighting.Changed:Connect(function(changedProperty) if changedProperty == "ClockTime" then if game.Lighting.TimeOfDay == 0 then game.Workspace.lightfolder:WaitForChild("streetlamp1").PointLight.Enabled = true else game.Workspace.lightfolder:WaitForChild("streetlamp1").PointLight.Enabled = false end end end)
You need to make the = sign into a double equal sign. This is because you are saying if game.Lighting.TimeOfDay = 0 which is saying if the of day is set to zero because one = sign is setting something to a value.
You would need to change the script to this -
if game.Lighting.TimeOfDay == 0 then -- Double equals sign game.Workspace.lightfolder.streetlamp1.PointLight.Enabled = true else game.Workspace.lightfolder.streetlamp1.PointLight.Enabled = false end