I’m trying to Optimise Dynamic Lighting by making a capped 5 lighting updated every frame
when frame reaches to 5 and there’s a wait it stops the thread with no errors at all
while true do
wait(0.3)
local cappedframe = 0
for _,v in pairs(workspace:GetDescendants()) do
cappedframe = cappedframe + 1
if cappedframe >= 5 then
cappedframe = 0
wait()
print("took a break")
end
end
end
The Purpose to Optimise?
It minimizes the spike lag and makes FPS much smoother to have a processor a short break to prevent slowdown issues.
I tried to solve it, and I through it related to renderstepped:Wait() stopping a thread, but all wait() stops refreshes.
Getting Sound Occlusion, raycasting / muffle the audio, depending on how hard surface is
Getting Light with Variable, raycasting / getting location and how close light is, change range / beam
Getting World’s Audios, raycasting too / muffles the audio, depending on how hard surface is
Your issue is probably going to be in there somewhere. Only having that information, I can’t really work out where the problem would be. This didn’t happen before you capped the lighting updates per frame?
When i added cappedframe value It’s stopped refreshing lights / sounds / others, it feels like it on wait forever by getdescendants even if i put cappedframe = 0 before wait()
Did i miss something?