Hi. I can clearly see the problem in this code, but sometimes it's harder to identify and can be quite time consuming in longer examples. I recommend you use print() statements and / or breakpoints to find where the particular problem is.
First off, we only really need to set math.randomseed(tick()) at the top of the script. Of course you can set it in the loop if you want to, I just don't know if you've been misled about needing to do that.
The problem arises where we have this statement:
B = (Brightness)
First, let's think about what B is. It's the Spotlight's Brightness property, right? We accessed the property correctly...so why isn't it working? That's because B is actually not a reference to the Brightness property.
In fact, when you declare B, it will hold the contents of whatever is at SpotLight.Brightness. Let's say this is the number 3.
So really, you've done an assignment of B = 3. Now we set B = Brightness. That will change the contents of the variable, 3, to the contents of the Brightness variable, but this won't actually change the property.
How do we fix this? Easy! We just set SpotLight.Brightness to the Brightness variable, like so:
SpotLight.Brightness = Brightness
Hope I could help. :) Good luck scripting!
2 comments
Fixed up your code blocks. I recommend you see what I changed.
Thanks. Couldn't figure out why they weren't working.