Light Attenuation Module


While the module is simple, it is good for trying to fix the problem with Roblox’s lighting system not including the attenuation function.

It could be used for games such as showcases or horror games so it gives a much more realistic feeling.

It could be improved by using the formula for light attenuation and being more customizable.


Sometimes, when you use light sources in your games so they look realistic, you get this weird falloff effect that just rubs you the wrong way. And sometimes, you don't want to make the light fade away the further it travels because it takes too much work.

That’s why I’ve made this module script to deal with it, while trying to be as realistic as performant as possible.

Examples (from a testing game)
A noob inside an old 2006 house with four lights everywhere.



Four folding chairs scattered everywhere all being highlighted by one spot light



How to use

This is how you should use the module:
  1. Insert the module and place it onto ReplicatedStorage or ReplicatedFirst.
  2. Insert a script (server or local) into an instance with a light source (or multiple) inside it.
  3. Write the script like this:
local module = require(game.ReplicatedStorage.LightFalloff)

module:ApplyFalloff(script.Parent, 0.5) -- 0.5 isn't needed as it's a default number for the intensity. 

And boom! You now have a more realistic lighting!


While the module is simple to use, it doesn't have as much customizability and can probably cause several artifacts to appear since Roblox isn't designed to handle that much lighting if used on at least ten instances with light sources inside them.

You cannot adjust the falloff effect without having to edit the module itself, which can be inconvenient since there are games that want style and not realism.

The module doesn’t use the formula for light attenuation, instead it uses (n - i) x intensity to simulate light attenuation, which can be unrealistic at times.


This is where you can help support this module so it can be used by big games such as "The Mimic" for a more realistic experience.