Just for those who were wanting the source code of the script, here it is:
Global Lighting Script:
GLOBAL ILLUMINATION
WARNING! THIS SCRIPT WILL CAUSE LAG IN LARGE TO MEDIUM SIZED GAMES, ONLY USE ON SMALL GAMES, ANYTHING ELSE MAY CAUSE CRASHING OR FREEZING
The "EnabledExtras" Feature adds some extra lighting changing instances to the lighting service
like color correction, bloom, and blur
The "Delay" is how long it will take before the lighting will fully update
local rayDirection = game.Lighting:GetSunDirection()
local rayLength = 125
if script.Configuration.EnabledExtra.Value == true then
if game.Lighting:FindFirstChild("LuminBloom") then
local bloom = game.Lighting:FindFirstChild("LuminBloom")
bloom.Enabled = true
bloom.Name = "LuminBloom"
bloom.Threshold = 0.8
bloom.Size = 56
bloom.Intensity = 0.2
else
local bloom = Instance.new("BloomEffect",game.Lighting)
bloom.Enabled = true
bloom.Name = "LuminBloom"
bloom.Threshold = 0.8
bloom.Size = 56
bloom.Intensity = 0.2
end
if game.Lighting:FindFirstChild("LuminColor") then
local cc = game.Lighting:FindFirstChild("LuminColor")
cc.Enabled = true
cc.Name = "LuminColor"
cc.Brightness = 0.2
cc.Contrast = 0.2
cc.Saturation = 0.2
else
local cc = Instance.new("ColorCorrectionEffect",game.Lighting)
cc.Enabled = true
cc.Name = "LuminColor"
cc.Brightness = 0.2
cc.Contrast = 0.2
cc.Saturation = 0.2
end
if game.Lighting:FindFirstChild("Luminblur") then
local blur = game.Lighting:FindFirstChild("Luminblur")
blur.Enabled = true
blur.Name = "Luminblur"
blur.Size = 2
else
local blur = Instance.new("BlurEffect",game.Lighting)
blur.Enabled = true
blur.Name = "Luminblur"
blur.Size = 2
end
end
game.Lighting:GetPropertyChangedSignal("TimeOfDay"):Connect(function()
rayDirection = game.Lighting:GetSunDirection()
end)
if not game.Workspace:FindFirstChild("Center") then
local cen = Instance.new("Part")
cen.Position = Vector3.new(0,0,0)
cen.Transparency = 1
cen.Anchored = true
cen.Size = Vector3.new(0.1,0.1,0.1)
cen.CanCollide = false
cen.CanQuery = false
cen.CanTouch = false
cen.Name = "Center"
cen.Parent = game.Workspace
end
local timer = 0
local timermax = script.Configuration.Delay.Value
game:GetService("RunService").Heartbeat:Connect(function(dt)
timer += dt
if timer >= timermax then
timer = 0
for i, v in pairs(game.Workspace:GetDescendants()) do
if not v:FindFirstChild("Lum") then
if v:IsA("PointLight") then
local range = v.Range
local part = v:FindFirstAncestorOfClass("Part")
for _, checking in pairs(game.Workspace:GetDescendants()) do
if checking:IsA("Part") or checking:IsA("UnionOperation") or checking:IsA("MeshPart") or checking:IsA("Truss") or checking:IsA("WedgePart") or checking:IsA("CornerWedgePart") then
if checking.Transparency < 0.75 and (checking.Position-part.Position).Magnitude <= range then
local par = {}
for _, is in pairs(game.Workspace:GetDescendants()) do
if is:IsA("Part") or is:IsA("UnionOperation") or is:IsA("MeshPart") or is:IsA("Truss") or is:IsA("WedgePart") or is:IsA("CornerWedgePart") then
if is.Transparency >= 0.75 or is.CastShadow == false then
table.insert(par,is)
end
end
end
local params = RaycastParams.new(par)
params.FilterType = Enum.RaycastFilterType.Blacklist
local ray = game.Workspace:Raycast(part.Position,(checking.Position-part.Position)*range,params)
if ray then
if (ray.Position-part.Position).Magnitude <= range and ray.Instance == checking then
local at = Instance.new("Attachment")
local lu = Instance.new("PointLight")
local ch = Instance.new("ObjectValue")
ch.Name = "Lum"
ch.Parent = lu
lu.Parent = at
lu.Range = (((range/2 * ((checking.Size.Y+checking.Size.X+checking.Size.Z)/6))*(v.Brightness*(range/50))))
if ray.Instance:FindFirstAncestorOfClass("Model") then
if ray.Instance:FindFirstAncestorOfClass("Model"):FindFirstChild("Humanoid") then
lu.Brightness = v.Brightness/15
else
lu.Brightness = v.Brightness/5
end
else
lu.Brightness = v.Brightness/5
end
lu.Color = ray.Instance.Color
lu.Shadows = true
at.WorldPosition = ray.Position
at.Parent = game.Workspace:FindFirstChild("Center")
local pos = ray.Position
spawn(function()
wait(timermax/2)
local ray1 = game.Workspace:Raycast(part.Position,(checking.Position-part.Position)*range,params)
if ray1 and at and pos ~= ray1.Position then
pos = ray1.Position
game:GetService('TweenService'):Create(at,TweenInfo.new(timermax/2,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{WorldPosition = ray1.Position}):Play()
game:GetService('TweenService'):Create(lu,TweenInfo.new(timermax/2,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{Range = (((range/2 * ((checking.Size.Y+checking.Size.X+checking.Size.Z)/6))*(v.Brightness*(range/50))))}):Play()
end
wait(timermax/2)
local ray2 = game.Workspace:Raycast(part.Position,(checking.Position-part.Position)*range,params)
if ray2 and at and pos ~= ray2.Position then
pos = ray2.Position
game:GetService('TweenService'):Create(at,TweenInfo.new(timermax/2,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{WorldPosition = ray2.Position}):Play()
game:GetService('TweenService'):Create(lu,TweenInfo.new(timermax/2,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{Range = (((range/2 * ((checking.Size.Y+checking.Size.X+checking.Size.Z)/6))*(v.Brightness*(range/50))))}):Play()
end
end)
end
end
end
end
end
elseif v:IsA("Part") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("Truss") or v:IsA("WedgePart") or v:IsA("CornerWedgePart") then
if v.Transparency < 0.75 then
local par = {}
for _, is in pairs(game.Workspace:GetDescendants()) do
if is:IsA("Part") or is:IsA("UnionOperation") or is:IsA("MeshPart") or is:IsA("Truss") or is:IsA("WedgePart") or is:IsA("CornerWedgePart") then
if is.Transparency >= 0.75 or is.CastShadow == false then
table.insert(par,is)
end
end
end
local params = RaycastParams.new(par)
params.FilterType = Enum.RaycastFilterType.Blacklist
local corners = require(script.PositionModule).GetCorners(v)
local isbounce = false
for _, corner in pairs(corners) do
if isbounce == false then
local ray = game.Workspace:Raycast(corner + rayDirection * rayLength,(corner - (corner + rayDirection * rayLength))*rayLength*2,params)
if ray then
if ray.Instance == v then
isbounce = true
local at = Instance.new("Attachment")
local lu = Instance.new("PointLight")
local ch = Instance.new("ObjectValue")
ch.Name = "Lum"
ch.Parent = lu
lu.Parent = at
lu.Range = (v.Size.X+v.Size.Y+v.Size.Z)/1.5
if ray.Instance:FindFirstAncestorOfClass("Model") then
if ray.Instance:FindFirstAncestorOfClass("Model"):FindFirstChild("Humanoid") then
lu.Brightness = 0.1
else
lu.Brightness = 0.2
end
else
lu.Brightness = 0.2
end
lu.Color = ray.Instance.Color
lu.Shadows = true
at.WorldPosition = ray.Position
at.Parent = game.Workspace:FindFirstChild("Center")
local pos = ray.Position
spawn(function()
wait(timermax/2)
local ray1 = game.Workspace:Raycast(corner + rayDirection * rayLength,(corner - (corner + rayDirection * rayLength))*rayLength*2,params)
if ray1 and at and pos ~= ray1.Position then
pos = ray1.Position
game:GetService('TweenService'):Create(at,TweenInfo.new(timermax/2,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{WorldPosition = ray1.Position}):Play()
end
wait(timermax/2)
local ray2 = game.Workspace:Raycast(corner + rayDirection * rayLength,(corner - (corner + rayDirection * rayLength))*rayLength*2,params)
if ray2 and at and pos ~= ray2.Position then
pos = ray2.Position
game:GetService('TweenService'):Create(at,TweenInfo.new(timermax/2,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{WorldPosition = ray2.Position}):Play()
end
end)
end
end
end
end
end
end
elseif v:FindFirstChild("Lum") then
v:FindFirstAncestorOfClass("Attachment"):Destroy()
end
end
end
end)
PositionModule:
local module = {}
module.GetCorners = function(part)
local cf = part.CFrame
local size = part.Size
local corners = {}
local frontFaceCenter = (cf + cf.LookVector * size.Z/2)
local backFaceCenter = (cf - cf.LookVector * size.Z/2)
-- edges
local topFrontEdgeCenter = frontFaceCenter + frontFaceCenter.UpVector * size.Y/2
local bottomFrontEdgeCenter = frontFaceCenter - frontFaceCenter.UpVector * size.Y/2
local topBackEdgeCenter = backFaceCenter + backFaceCenter.UpVector * size.Y/2
local bottomBackEdgeCenter = backFaceCenter - backFaceCenter.UpVector * size.Y/2
-- center
corners.center = part.Position
-- corners
corners.topFrontRight = (topFrontEdgeCenter + topFrontEdgeCenter.RightVector * size.X/2.5).Position
corners.topFrontLeft = (topFrontEdgeCenter - topFrontEdgeCenter.RightVector * size.X/2.5).Position
corners.topBackRight = (topBackEdgeCenter + topBackEdgeCenter.RightVector * size.X/2.5).Position
corners.topBackLeft = (topBackEdgeCenter - topBackEdgeCenter.RightVector * size.X/2.5).Position
return corners
end
return module
``