Atmosphere turns red the more an npc gets close

hi, i want the atmosphere to get gradually red from its original color the more the player is close to an object. obviously i want it to be local, so that only the player in question sees it. i think i should use magnitude but i’ve never understood how to use it. thank you!

I have written an example code that uses magnitude to calculate and adjust the atmosphere color. The closer the player is, the more the color shifts towards red:

local player = game.Players.LocalPlayer
local npc = workspace.Rig -- Your NPC Model
local ColorCorrection = game.Lighting.ColorCorrection
local originalColor = ColorCorrection.TintColor
local RedColor = Color3.fromRGB(255, 0, 0)

while task.wait() do
	local distance = (npc:WaitForChild("HumanoidRootPart").Position - player.Character.HumanoidRootPart.Position).magnitude
	local t = math.clamp(distance / 50, 0, 1)
	ColorCorrection.TintColor = originalColor:Lerp(RedColor , 1 - t)
end

I have used ColorCorrection to set the color, feel free to change it if you want!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.