I seem to be having an issue without any clear way to actually fix it, and I am little hesitant to try anything drastic to the script.
--local Players = game:GetService("Players")
--local player = Players.LocalPlayer
local Character = script.Parent
local humanoid = Character:WaitForChild("Humanoid")
local Lighting = game:GetService("Lighting")
--local blackScreen = Lighting:WaitForChild("BlackScreen")
game.Lighting.BlackScreen.Enabled = false
--local deathContrast = Lighting:WaitForChild("DeathContrast")
game.Lighting.DeathContrast.Enabled = false
game.Lighting.DeathContrast.Contrast = 0
--local InfectionBlur = Lighting:WaitForChild("InfectionBlur")
game.Lighting.InfectionBlur.Size = 0
local RAY_LENGTH = 21
local INFECTION_VALUE = 0
print(rayDirection)
game:GetService("RunService").Heartbeat:Connect(function()
print("Running")
local RAY_DIRECTION = Lighting:GetSunDirection()
local NEW_RAY= Ray.new(Character.PrimaryPart.Position,RAY_DIRECTION * RAY_LENGTH)
local RAY_RESULT= workspace:FindPartOnRay(NEW_RAY,Character)
if not RAY_RESULT and INFECTION_VALUE < 100 then
print("Sunlight")
game.Lighting.InfectionBlur.Size += .8
INFECTION_VALUE += .8
elseif RAY_RESULT and INFECTION_VALUE > 0 then
print("No Sunlight")
game.Lighting.InfectionBlur.Size -= .6
INFECTION_VALUE -= .25
end
if INFECTION_VALUE >= 100 then
game.Lighting.BlackScreen.Enabled = true
task.wait(.1)
game.Lighting.BlackScreen.Enabled = false
game.Lighting.DeathContrast.Enabled = true
game.Lighting.DeathContrast.Contrast += 4
Character:WaitForChild("Humanoid").WalkSpeed = 1
task.wait(1.3)
humanoid:TakeDamage(999)
end
end)
The issue is the lighting effects also appear for the person that is not in the sun, which is not the desired effect.