I know this is very amateur but i don't know how I would make it do what the title entails.
This is what i have so far:
L = script.Parent.PointLight.Brightness function RNG() local N = math.random(.1,1.2) L = N end while true do wait(math.random(.3,.7)) RNG() end
I want to make it so each time the function is called it generates a new number. The function call works; however, the brightness of the point light doesn't change.
Hello There,
You Can Use return to get a number.(Also you can't include decimals in math.random use Random.new():NextNumber(num1, num2) )
L = script.Parent.PointLight function RNG() local N = Random.new():NextNumber(.1,1.2) return N end while true do wait(Random.new():NextNumber(.3,.7)) L.Brightness = RNG() end
The variable L does not reference the Brightness property of the point light; rather, it simply returns the current value of brightness. So whenever you change L to N, you are only changing the variable L, and not the brightness property of the point light.
I would do it like this instead:
L = script.Parent.PointLight function RNG() local N = math.random(.1,1.2) L.Brightness = N end while true do wait(math.random(.3,.7)) RNG() end
turns out this is the fixed version:
L = script.Parent.PointLight function RNG() local N = math.random(.1,1.2) L.Brightness = N end while true do wait(math.random(.3,.7)) RNG() end
For whatever reason making it so the brightness is referenced inside the function causes it to work.