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)
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)