So. I have a script in which when the time reaches 21:00:00, or 9pm, the scripts to open a gate stop working and then when the time reached 6:00:00 it re-activates.... BUT, it doesn't work, could someone help?
So. I have 3 different codes which all don't work, making even 1 of them work would be a miracle
game.Lighting.LightingChanged:connect(function(TimeOfDay) if TimeOfDay then game.Workspace.Security.Rear.Open.R.Enabled = false game.Workspace.Security.Rear.Open.L.Enabled = false game.Workspace.Security.Front.Open.R.Enabled = false game.Workspace.Security.Front.Open.L.Enabled = false else game.Workspace.Security.Rear.Open.R.Enabled = true game.Workspace.Security.Rear.Open.L.Enabled = true game.Workspace.Security.Front.Open.R.Enabled = true game.Workspace.Security.Front.Open.L.Enabled = true end end)
if game.Lighting.TimeOfDay == "21:00:00" then game.Workspace.Security.Rear.Open.R.Enabled = false game.Workspace.Security.Rear.Open.L.Enabled = false game.Workspace.Security.Front.Open.R.Enabled = false game.Workspace.Security.Front.Open.L.Enabled = false elseif game.Lighting.TimeOfDay == "06:00:00" then game.Workspace.Security.Rear.Open.R.Enabled = true game.Workspace.Security.Rear.Open.L.Enabled = true game.Workspace.Security.Front.Open.R.Enabled = true game.Workspace.Security.Front.Open.L.Enabled = true end
game.Lighting.TimeOfDay.Changed:connect(function() if game.Lighting.TimeOfDay == "21:00:00" then -- Night game.Workspace.Security.Rear.Open.R.Disabled = true game.Workspace.Security.Rear.Open.L.Disabled = true game.Workspace.Security.Front.Open.R.Disabled = true game.Workspace.Security.Front.Open.L.Disabled = true elseif game.Lighting.TimeOfDay == "6:00:00" then --Day game.Workspace.Security.Rear.Open.R.Disabled = false game.Workspace.Security.Rear.Open.L.Disabled = false game.Workspace.Security.Front.Open.R.Disabled = false game.Workspace.Security.Front.Open.L.Disabled = false end end)
Nvm, I just realized that you could just make it a loop to check for it all the time. Here you go:
while wait() do if game.Lighting.TimeOfDay == "21:00:00" then game.Workspace.Security.Rear.Open.R.Enabled = false game.Workspace.Security.Rear.Open.L.Enabled = false game.Workspace.Security.Front.Open.R.Enabled = false game.Workspace.Security.Front.Open.L.Enabled = false elseif game.Lighting.TimeOfDay == "06:00:00" then game.Workspace.Security.Rear.Open.R.Enabled = true game.Workspace.Security.Rear.Open.L.Enabled = true game.Workspace.Security.Front.Open.R.Enabled = true game.Workspace.Security.Front.Open.L.Enabled = true end end
I bet you put this script in Lighting, put it somwhere like Workspace or ServerScriptService