Roblox Studio Tutorials - June 6, 2022

How to Change Light Color Clicking a Button


Buzzy Beth


Download – Change Light Script

How To – Change Light Color Clicking a Button in Roblox Studio

What’s up everyone, BuzzyBeth here – In this tutorial we’ll be learning how change the color of a light when clicking a button!

  • I have a spotlight inside of a part named “bulb”, so if you use a pointlight, spotlight, either light is okay just make sure you know where it’s at because we will be referencing that in just a second.
  • Now inside of my button i’m gonna go ahead and add a script as well as a clickdetector.
  • Inside of my script go ahead and delete your print statement. We have a variable for our bulb which is the part where my spotlight is at. We’re going to go ahead and create a variable for our button as well as our clickdetector.
  • We’re going to create a function on click and do it so that anytime a player clicks on our button then the spotlight inside of our bulb is going to change to a random color.
  • You could technically set it to any color that you want, but for me I want to go ahead and change it to a random color. So as you can see I have math.random(0, 255) for my r,g and b values.
  • Then i’m going to go ahead and call my function.