You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I am trying to reduce lag overall, but one issue that is the most problematic is my street light script. -
What is the issue? Include screenshots / videos if possible!
Everytime my streetlight script runs:
local descendants = game.Workspace.StreetLightsCombined:GetDescendants()
local Light = game.ReplicatedStorage.StreetLight
-- SET FOR WHEN FIRST MADE
if game.Lighting.ClockTime >= 6.5 and game.Lighting.ClockTime <= 17.7 then
--print("1124")
-- off
for index, descendant in pairs(descendants) do
--print("1124")
--print(descendant.Name)
if descendant.Name == "StreetLightBulbI" then
print("1124")
if descendant:IsA("MeshPart")then
print("1124")
descendant.Transparency = 0
descendant.BrickColor = BrickColor.new("Institutional white")
descendant.Material = "ForceField"
local steetLightClone = Light:Clone()
steetLightClone.Parent = descendant
steetLightClone.Brightness = 0
print("HAAAA")
end
end
end
elseif game.Lighting.ClockTime <= 6.5 or game.Lighting.ClockTime >= 17.7 then
print("1124")
-- on
for index, descendant in pairs(descendants) do
--print("1124")
if descendant.Name == "StreetLightBulbI" then
-- print("1124")
if descendant:IsA("MeshPart")then
print("1124")
descendant.Transparency = 0
descendant.BrickColor = BrickColor.new("Institutional white")
descendant.Material = "Neon"
local steetLightClone = Light:Clone()
steetLightClone.Parent = descendant
steetLightClone.Brightness = 2.14
print("AHHHH")
end
end
end
else
print("HUH")
end
---------------------
local part = game.Lighting
-- Save the current state
local currentTime = part.ClockTime
local function onBrickColorChanged()
local newTime = part.ClockTime
--print("Color changed from " .. currentTime .. " to " .. newTime)
currentTime = newTime
--print("TIMEEEE")
print(newTime)
if newTime < 6.5 and newTime > 6.35 then
for index, descendant in pairs(descendants) do
--print("1124")
--print(descendant.Name)
if descendant.Name == "StreetLightBulbI" then
print("1124")
if descendant:IsA("MeshPart")then
print("1124")
descendant.Transparency = 0
descendant.BrickColor = BrickColor.new("Institutional white")
descendant.Material = "ForceField"
descendant.StreetLight.Brightness = 0
print("HAAAA")
end
end
end
elseif newTime < 17.7 and newTime > 17.5 then
for index, descendant in pairs(descendants) do
--print("1124")
if descendant.Name == "StreetLightBulbI" then
-- print("1124")
if descendant:IsA("MeshPart")then
print("1124")
descendant.Transparency = 0
descendant.BrickColor = BrickColor.new("Institutional white")
descendant.Material = "Neon"
descendant.StreetLight.Brightness = 2.14
print("AHHHH")
end
else
print("Else")
end
end
else
print("Else")
end
end
part:GetPropertyChangedSignal("ClockTime"):Connect(onBrickColorChanged)
it lags a LOT. I know that there’s probably an easier way to do this, and that’s why I’m here for help. I got some help from other Roblox communities but my lag persisted every time the lamps would turn on.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve (as you can see) tried to put the light part into the lamp when the script first runs then I enable and disable them accordingly.