Our development team have encountered a potential engine bug while making a flashlight system.
We had never experienced this before in any other projects we’ve worked on.
The flashlight works by simply creating a part with a spotlight and while using RenderStepped, sets the part’s CFrame to the camera’s CFrame. And once activated again, just disconnects the connection and deleted the part.
I have tested the same exact code on another project with another game and the FPS was steady and didn’t change. So this must be that the map is more highly detailed and bigger?
In the game where the issue occurs
This is how the frame rate looks normally (100 - 140+) without the flashlight:
Does the SpotLight have .Shadows enabled? This can cause a significant performance loss if there are too many objects casting shadows, as they have to be rendered twice, once for the player to see and once for the light source to figure out what should be casting shadows. You can combat the extre rendering by reducing the .Range and .Angle of the SpotLight.
Just following up on this thread to see if this is still an issue for you! What others have mentioned in this thread is correct; if your spotlight has shadows enabled the cost of rendering the light can increase significantly if it moves around every frame (which it sounds like it does), especially in Future lighting mode.