Help needed with gui light

So I’ve been working on this RGB light controller Gui. And I need help making the 2 brightness buttons work.

See the two brightness buttons at the top left corner? I need to make it so when you click the up arrow one it goes up one brightness per click and the same but one down in brightness for the down arror. Sorry if this seems complicated.

Btw heres the script for each rgb button:

Thanks for helping me out :slight_smile:

1 Like

If you got some issue with my scripts, please let me know, i will try to fix it

local button = script.Parent
local Light = workspace.MYLED.YOUR_LIGHT

button.MouseButton1Click:Connect(function()
       if Light.Brightness < MAX_BRIGHTNESS then
       Light.Brightness = Light.Brightness + 1 --You can replace with - 1 at here.
    end
end)

Thank you. I’ll go test it out.

1 Like

Theres an error at MAX_BRIGHTNESS

That’s just a placeholder. I recommend changing:

if Light.Brightness < MAX_BRIGHTNESS then
	Light.Brightness = Light.Brightness + 1 
end

to

Light.Brightness = math.clamp(Light.Brightness + INCREMENT, MIN_BRIGHTNESS, MAX_BRIGHTNESS) 

Basically, this would just cap out the property. You can change INCREMENT, MIN_BRIGHTNESS, or MAX_BRIGHTNESS to whatever you wish. If you want an example, here you go:

Light.Brightness = math.clamp(Light.Brightness + 1, 0.25, 5) 

If you have any questions, feel free to reply.

No, that’s meant how bright your light could be, and the local Light meaning where your light is (example : workspace.MYLED.Light)