ColorCorrection not changing from script

I have a script that should change the ColorCorrection “TintColor” to be completely black, but when I hit the part that enables the script, it doesn’t change anything.

local triggerC = game.Workspace.triggerCrackling
local ambientColor = game.Workspace.Lighting.ColorCorrection

function onPartTouched(triggerC)
	ambientColor.TintColor = Color3.new(0, 0, 0)
	wait(1)
	ambientColor.TintColor = Color3.new(255, 255, 255)
end

triggerC.Touched:Connect(onPartTouched)

Any help is appreciated! :slight_smile:

replace game.Workspace.Lighting with game:GetService(“Lighting”) and try it

The “game:GetService(“Lighting”)” is underlined with red, and so as if I add “.ColorCorrection” to it.

[EDIT] also doesn’t work.

did you put the colorcorrection effect into lighting or is it in workspace?
if it’s in workspace, try moving it to lighting

Try this

local triggerC = game.Workspace.triggerCrackling
local ambientColor = game:GetService("Lighting").ColorCorrection

function onPartTouched()
	ambientColor.TintColor = Color3.fromRGB(0, 0, 0)
	task.wait(1)
	ambientColor.TintColor = Color3.fromRGB(255, 255, 255)
end

triggerC.Touched:Connect(onPartTouched)

(edited, and it works for me)
Also, if you want to make it work only when a player has touched it, do this:

local triggerC = script.Parent
local ambientColor = game:GetService("Lighting").ColorCorrection
local Players = game:GetService("Players")

function onPartTouched(Object)
	if Object.Parent:FindFirstChild("Humanoid") then
		if Players:FindFirstChild(Object.Parent.Name) then
			ambientColor.TintColor = Color3.fromRGB(0, 0, 0)
			task.wait(1)
			ambientColor.TintColor = Color3.fromRGB(255, 255, 255)
		end
	end
end

triggerC.Touched:Connect(onPartTouched)

[If you want to have a debounce, simply do this:]

local triggerC = script.Parent
local ambientColor = game:GetService("Lighting").ColorCorrection
local Players = game:GetService("Players")
local db = false

function onPartTouched(Object)
	if Object.Parent:FindFirstChild("Humanoid") then
		if Players:FindFirstChild(Object.Parent.Name) then
           if db == false then
              db = true
              ambientColor.TintColor = Color3.fromRGB(0, 0, 0)
		  	  task.wait(1)
			  ambientColor.TintColor = Color3.fromRGB(255, 255, 255)
              task.wait(3)
              db = false
           end
		end
	end
end

triggerC.Touched:Connect(onPartTouched)
2 Likes

This worked very well!

Thanks for the help! :slight_smile:

1 Like