Why does this work...
repeat script.Parent.Reflectance = script.Parent.Reflectance+0.1 wait(0.2) until script.Parent.Reflectance == 1
and this one doesn't?
local a = script.Parent.Reflectance repeat a = a+0.1 wait(0.2) until a == 1
Wanted to clear up my curiosity.
Problem
Declaring the variable "a" in the second loop is saving the object's reflectance as a number - it is not holding a reference to the reflectance property.
When is it appropriate to declare a variable then?
Instead of just creating a variable that holds a number, and changing that number (which evidently will not update the property), you should create one referencing the object you're trying to change - to shorten your code and make it look nicer. Here's an example:
-- You should also make your variable names memorable, instead of just using random characters. local parent = script.Parent repeat wait(0.1) parent.Reflectance = parent.Reflectance + 0.1 until parent.Reflectance >= 1
This same logic applies with anything else you're trying to change. You want to create a reference to another reference - not it's value if you are to change it.