What is the issue? Include screenshots / videos if possible!
I don’t know ANYTHING about scripting lighting.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I was searching everywhere, but only found a video showcasing it but not showing the script.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Using CollectionService, you can easily do a Baldi like lighting system by adding tags to objects that emits light and objects that receives it.
You can easily set attributes on parts that you tag as “LightEmitter” so you can edit them for your crazy needs like schoolhouse escape or flickering the lights with The Test.
Here is a simple code to achieve that effect using only parts. It’s up to you to edit it so this supports textures/decals. I also provided a small test place below so you can start experimenting with it. Have fun!
local CollectionService = game:GetService("CollectionService")
-- The complexity of this code is O(n * m)
-- If you do add alot of lights, be sure to call this function when needed.
local function UpdateLights()
for _,receiver:Part in CollectionService:GetTagged("LightReceiver") do
-- starts black
local finalColor = Color3.new(0,0,0)
for _,emitter in CollectionService:GetTagged("LightEmitter") do
-- Calculate the distance
local emitterRange = emitter:GetAttribute("Range") :: number
local distance = (receiver.Position - emitter.Position).Magnitude
local distancePercentage = (emitterRange-distance) / emitterRange
-- Distance is too far, skip
if (distance > emitterRange) then
continue
end
local emitterColor = emitter:GetAttribute("Color") :: Color3
local emitterIntensity = emitter:GetAttribute("Intensity") :: number
-- Calculate each color depending on the distance
local r = math.clamp(finalColor.R + emitterColor.R * distancePercentage, 0,1)
local g = math.clamp(finalColor.G + emitterColor.G * distancePercentage, 0,1)
local b = math.clamp(finalColor.B + emitterColor.B * distancePercentage, 0,1)
finalColor = Color3.new(r,g,b)
end
receiver.Color = finalColor
end
end
-- In the original Baldi's Basics Game,
-- lights are updated only when they are changed.
-- For example, when the player looks at Timmy The Test,
-- it calls FlickerLights which update the lights
-- In this example, the lights are updated continously so you can run
-- on Studio and move the parts to see the changes in real time
while true do
UpdateLights()
task.wait()
end
what are you actually trying to achieve? this lighting can easily be accomplished without any scripts, just point, surface, etc lights. roblox already has light objects, you may just need to tweak the lighting settings to get the correct look