I am trying to make a disco light. I have it set up so when I click a button a loop will happen and switch between colors. But in order for that to work I first need to find out how to change the pointlight color in a script. In order for me to set up the loop I need to figure this out first.
local Light9 = game.Workspace.Light9.PointLight function onClicked(playerWhoClicked) Light9.Brightness = 100 Light9.Range = 60 Light9.Color --This is where I need help. end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Color
is a Color3
value. Set it by doing Light9.Color = Color3.new(red, green, blue)
, where the three colors are the rgb components of the color from 0
to 1
.
To make those random, you can use math.random()
, which returns a random value in the range [0, 1)
: Light9.Color = Color3.new(math.random(), math.random(), math.random())
.
Alternatively, like kingdom5 said, you can get a random BrickColor
and convert it into a Color3
by doing Light9.Color = BrickColor.Random().Color
.
Quick note: If you are given values in the standard color range 0-255 like (255, 127, 63), you can make a Color3
out of those by simply dividing all of them by 255 to put them in the correct range: Color3.new(255/255, 127/255 , 63/255)
You need to give the man an example to really make ti go through man. c:
local light = game.Workspace.Part.PointLight light.Color = Color3.new(4, 175, 250) --cyan
:p