Im having a issue with a light system on a tower

I am making a block so it changes the Colour of it I cant seem to figure it out here is my code:

while true do
game.Workspace.TowerLight1.Properties.Color = “Gold”
wait(1)
game.Workspace.TowerLight1.Properties.Color = “Really Black”
end

I’m assuming TowerLight1 is some sort of light object.

If you’re trying to change its color, you don’t need to specify Properties, as that’s what those fields are referred to as. Change it like this:

workspace.TowerLight1.Color = BrickColor.new("Gold").Color
1 Like

If you was to make it turn on at a certain point time of the day how would that look?

1 Like

You can set its Enabled property as well.

workspace.TowerLight1.Enabled = true --//Can also be false.
1 Like

Thx i will have to figure out how much seconds are in my day / night script

1 Like

I think you could do this

Turn light off at a specific time

remember, if you’re using a model, select the part that has a light/neon material

local lighting = game:GetService("Lighting")
local TowerLight = game.Workspace.TowerLight1

if lighting.ClockTime == 20 then 
-- set 20 to whatever hour; 
-- Roblox uses military time so 15 means 3 pm, 15.5 means 3:30 pm
-- If you want, you could instead use lighting.TimeOfDay, however
-- This means you would also have to include colons (i think)
-- Such as 15:00:00 = 3 pm, 15:30:00 = 3:30 pm

TowerLight.Material = "SmoothPlastic" 
-- If you're using neon to show light, set SmoothPlastic to the original material
-- If you're using a pointlight use
TowerLight.PointLight.Enabled = false
-- Same with SpotLight, SurfaceLight
end

if you want to turn the light on, do the opposite:

Turn light on at a specific time
local lighting = game:GetService("Lighting")
local TowerLight = game.Workspace.TowerLight1
-- if you're doing both of these in the same script you don't have to re-enter the variables

if lighting.ClockTime == 5 then 
-- Set 5 to whatever hour; 
-- Roblox uses military time so 5 means 5 am, 5.5 means 5:30 am
-- Again, you can use TimeOfDay if you want, but I don't recommend it

TowerLight.Material = "Neon" 
-- If you're using neon to show light, set Neon to the bright material
-- If you're using a pointlight use
TowerLight.PointLight.Enabled = false
-- Same with SpotLight, SurfaceLight
end

If you want to always check what time it is, you can just put both scripts in a loop
(make sure to add a wait at the end, and include if, that way it only checks if the time is this or that and doesn’t go through 100 lines of code to tell you what time it is)

Hope this helps, I haven’t tested it, so you might need to tweak some things. This only works if you either manually change the time of day or have a script that changes the time:

Basic automatic time system
--for example, you could use this
local lighting = game:GetService("Lighting")
while true do
  lighting.ClockTime += .1 --increases what time it is
  --meaning, again, that .5 is half an hour
  wait(2) --waits for two seconds, then repeats forever
end

A lot of this is common knowledge, so you can just ignore most of my little comments if you already know the basics.

Do I need some sort of time checker for it to function it didn’t work with it to turn on unless I am having a dumb moment.

Well you’re asking if you can turn it on at a certain time of day. You could use other Operators such as >= or <=

If you was to make it turn on at a certain point time of the day how would that look?

should I use the code you said for basic automatic time system

–for example, you could use this
local lighting = game:GetService(“Lighting”)
while true do
lighting.ClockTime += .1 --increases what time it is
–meaning, again, that .5 is half an hour
wait(2) --waits for two seconds, then repeats forever
end