Changing a property from variable?
So this probably looks like a horrid script that's broken but that's mostly because I haven't tested it. HungryJaffer said it would just index the property. Is this possible to do:
so instead of saying
script.Parent.Parent.Parent.BackgroundColor3 = Color3.new(125/255,125/255,125/255)
you would only instead have to do
change(script.Parent.Parent.Parent,BackgroundColor3, 125/255,125/255,125/255)
01 | function change(item, property, whattochangeto) |
02 | local propertytypes = { UDim 2 = { "UDim2.new" , "Size" , "Position" } ,Color 3 = { "Color3.new" , "BackgroundColor3" , "BorderColor3" , "TextColor3" , "TextStrokeColor3" , "ImageColor3" } } |
03 | for key,index in pairs (#propertytypes) do |
04 | for key 2 ,index 2 in pairs (#index) do |
05 | if property = = index then |
06 | item [ property ] [ index 2 ] = propertytypes [ index [ 1 ] ] (whattochangeto) |
08 | item [ property ] = whattochangeto |