Help making a button that changes the saturation (black & white)

I am trying to make a gui button that players can use to change the experience’s saturation. (Turn black and white, then back to normal when clicked again.)

This is the script I have right now. It changes the saturation to -1 but doesn’t change it back to zero.

I tried making a separate button with the same script (-1 changed to zero) but that didn’t work. What should I add or change so that the button will change the saturation to -1 then back to zero when clicked again? Any help is greatly appreciated!

1 Like
local colorcorrection = Instance.new("ColorCorrectionEffect")
colorcorrection.Parent = game.Lighting

script.Parent.MouseButton1Click:Connect(function()
colorcorrection.Saturation = (1 and colorcorrection.Saturation == -1) or -1
end)

What I did was add an additional logical statement to what ColorCorrection.Saturation should be. When -1, it will switch to 1, and vice versa.

As a side note, is the script a LocalScript? If not, it will replicate to all clients, which is likely what you don’t want.

2 Likes

This helps so much!! Thank you!

It would need to be a local script, otherwise the saturation change would replicate to each client.

1 Like