I was wondering if my scripts are efficient, but I’m also thinking that it could be improved for minimal lag.
This is the script in ReplicatedStorage
module.mod = function()
local DT = game.Lighting.ClockTime
if DT >= 6.00 and DT < 17.00 then
return "NO"
elseif DT >= 17.00 or DT < 6.00 then
return "YES"
else
return "MAYBE"
end
end
return module
This is the script that is in all the streetlights
local LightBulb = script.Parent.Parent.GlassShell
local data = require(game.ReplicatedStorage.CheckModule)
local ParticleEmitter = script.Parent.Parent.Head.Particle.ParticleEmitter
while true do
local result = data.mod()
if result == "YES" then
script.Parent.Material = Enum.Material.Neon
script.Parent.SpotLight.Enabled = true
script.Parent.Parent.Beam.Beam.Beam.Enabled = true
LightBulb.Transparency = 1
else
script.Parent.Material = Enum.Material.SmoothPlastic
script.Parent.SpotLight.Enabled = false
script.Parent.Parent.Beam.Beam.Beam.Enabled = false
LightBulb.Transparency = 0.1
end
wait(30)
end
It already lags at night, but I’m thinking it is just how many streetlights are on. I’m not quite sure if this is the best way to turn on the streetlights because I don’t feel like I should have a script for every streetlight. I was wondering if I need to fix this and how.