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!
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