A script that when a player touches a brick, the lighting changes only for the player, and it adds fog too. When somebody touches it, it works fine, but when they die, it stops working and everything turns bright, fog also goes away, even when touched. The script went inside Starter Gui. The second part went inside ServerScriptService.

local Color = Color3.new(1,1,1)
local Time = "12:00:00"
local End = 40000000
local ColorFog = Color3.new(1,1,1)

local Lighting = game:GetService("Lighting")

local function updateLighting()
	Lighting.Ambient = Color
	Lighting.TimeOfDay = Time
	Lighting.FogEnd = End
	Lighting.FogColor = ColorFog
end

Lighting.Changed:connect(function()
	updateLighting()
end)

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
while not Player do Player = Players.LocalPlayer wait() end
local Character = Player.Character
while not Character do Character = Player.Character wait() end

local function handleTouch(p)
	if p.Name == "AmbientBlock" then
		Color = p.AmbientColor.Value
		updateLighting()
	elseif p.Name == "TimeBlock" then
		Time = p.TimeValue.Value
		updateLighting()
	elseif p.Name == "FogBlockEnd" then
		End = p.FogEnd.Value
		updateLighting()
	elseif p.Name == "FogBlockColor" then
		ColorFog = p.FogColor.Value
		updateLighting()
end
end
for _, obj in pairs(Character:GetChildren()) do
	if obj:IsA("Part") then
		obj.Touched:connect(handleTouch)
	end
end

. . .

settings = {
	["TimeOfDay"] = 14;
	["Ambient"] = Color3.new(1,1,1)
	
}

local Lighting = game:GetService("Lighting")

Lighting.Changed:connect(function()
	for setting, value in pairs(settings) do
		Lighting[setting] = value
	end
end)