Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Changing a property from variable?

Asked by
NotSoNorm 777 Moderation Voter
8 years ago

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)

function change(item, property, whattochangeto)
    local propertytypes = {UDim2={"UDim2.new","Size","Position"},Color3={"Color3.new","BackgroundColor3","BorderColor3","TextColor3","TextStrokeColor3","ImageColor3"}}
    for key,index in pairs (#propertytypes) do
        for key2,index2 in pairs (#index) do
            if property == index then
                item[property][index2] = propertytypes[index[1]](whattochangeto)
            else
                item[property] = whattochangeto
            end
        end
    end
end
0
Did you test the script? Test it first and let us know if it works and what errors you're getting. TurboFusion 1821 — 8y

Answer this question