Ok here is what I have tried so far in the script
Light = script.Parent.Tile.PointLight.Color while true do wait (0.2) Light.Color = Color.Random(0,0,0) end
It is a normal script that is located inside a brick called Tile which has a PointLight in it .
I'm not entirely sure that Color.Random()
exists in Lua, but you can get the same affect by combining Color3 with math.random()
.
Also, line 1 references the Color property of the light. Did you mean to reference the light?
Light = script.Parent.Tile.PointLight while true do wait (0.2) Light.Color = Color3.new(math.random(), math.random(), math.random()) end
Hope this helped.
**Light = script.Parent.Tile.PointLight.Color** while true do wait (0.2) **Light.Color = Color.Random(0,0,0)** end
You define the 'Light' variable ending with .Color and then attempt to do Light.Color which is basically doing
script.Parent.Tile.PointLight.Color.Color
Which wouldn't work and also Color.Random isn't a method. Here's how you should tackle something like this:
local Light = script.Parent.Tile.PointLight -- Defining the PointLight instance while wait(0.2) do -- Shorter than doing while true do wait(2) code end local Random1 = math.random(255) local Random2 = math.random(255) local Random3 = math.random(255) Light.Color = Color3.new(Random1/255,Random2/255,Random3/255) end
I advice studying up on:
http://wiki.roblox.com/index.php?title=Random_numbers and http://wiki.roblox.com/index.php?title=Color3
All the best.
Hello brandonkludke2,
Your question has already been answered, but I would just like to quickly clear some things up.
There was an answer which suggested using math.random
. This is a start for picking a random Color3
color, and does indeed bring more variety, BUT there is another method which has less variety, but is much easier to remember.
First of all, I recommend taking a look at the properties and constructors of BrickColor
here.
We'll be using the Random
constructor and the Color
property.
Now, onto your script.
BrickColor.Random()
Returns a random BrickColor.
Adding .Color
after the parenthesis would return the Color3 value of the BrickColor value.
local Light = script.Parent.Tile.PointLight.Color while true do wait (0.2) Light.Color = BrickColor.Random().Color -- Random BrickColor and returning the Color3 value. end
I hope this helped! If you found this helpful, please don't forget to accept this answer. -Vrakos