How to make Beams turn on at a specific time?

Basically, I am trying to make beams turn on only at a certain time. I know you can do this with lights but I don’t know how to do it with beams. I don’t want the beams to show during daytime in my game.


I want them to turn on at 6pm and turn off around 6am.
I have searched the YouTube and the Forum but I didn’t really get the clear answer to what I am looking for. If anyone can help me it would be really appreciated. Thanks!

You would need to insert a Script into the light Part

Do you have a time system in the Game?

I do have a time system in my game set already yes.

Is time set with a Number or Int Value?

1 Like

Im sorry. Do you mind showing me an example of what it is? I’m not that advanced at scripting sorry.


There

Its ok nothing to be sorry about

Insert a number value into the server storage

ok I put the number value in server storage

if you want I can give you my discord

sure that would help RedMelon#8350

alright mines will be Hakosuka (slashed o)#8450

Is there no property such as Enabled in the lights? If there is, you could just do Enabled = true or Enabled = false when the time hits 6pm/6am.

See, I get what you mean I just don’t know how to type the full thing. Im not really much of a scripter.

Could you provide a screenshot of the properties of the light?

Try using this. The script is inserted into the beam object itself:

(sorry idk how to do the propper code format on this forum)
b = script.Parent

local oh,om = 6,10 – Open Time (hours,minutes)
local ch,cm = 17,30 – Close Time (hours, minutes)

local l = game:service(“Lighting”)
if (om == nil) then om = 0 end
if (cm == nil) then cm = 0 end

function TimeChanged()
local ot = (oh + (om/60)) * 60
local ct = (ch + (cm/60)) * 60
if (ot < ct) then
if (l:GetMinutesAfterMidnight() >= ot) and (l:GetMinutesAfterMidnight() <= ct) then
b.Enabled = false
else
b.Enabled = true
end
elseif (ot > ct) then
if (l:GetMinutesAfterMidnight() >= ot) or (l:GetMinutesAfterMidnight() <= ct) then
b.Enabled = false
else
b.Enabled = true
end
end
end

TimeChanged()
game.Lighting.Changed:connect(function(property)
if (property == “TimeOfDay”) then
TimeChanged()
end
end)

If you look at developer.roblox.com you’ll find this page that says how to do it with lights.
If you make it turn the Beams off/on using the Enabled property then it’ll work the same.
Documentation - Roblox Creator Hub

sou_p I appreciate the help. RoyalLiam is helping me through Discord though. Thanks though!

All fixed Over dms. Virus also removed!