Ambient.Color3 won't subtract multiple times

Hello, I’m writing a code that makes ambient.color3 decrease by 5 every time the block is clicked, but it only goes down once. Like from 138 to 133 and then won’t. I wrote the code here. I’m looking forward to your help.

local R,G,B = 138,138,138;
R, G, B = R-5, G-5, B-5
workspace.Part.ClickDetector.MouseClick:Connect(function()
game:GetService(“Lighting”).Ambient = Color3.fromRGB(R,G,B)
end)

This is a simple fix. Change your code to this:

local R,G,B = 138,138,138;
workspace.Part.ClickDetector.MouseClick:Connect(function()
R, G, B = R-5, G-5, B-5
game:GetService(“Lighting”).Ambient = Color3.fromRGB(R,G,B)
end)

In your code, it is only subtracting by 5 once, because you set the subtraction before the clicked event. You need to put it after the clicked event.

@Jab2Roblox Thank you so much!

1 Like

No problem! It you found my answer helpful, please mark it as the solution!

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