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

Script Not Changing Properties Of Gui When Looping Through Table Of Properties?

Asked by
LuaDLL 253 Moderation Voter
3 years ago
Edited 3 years ago

It is supposed to make the gui fade in but it doesnt change any of the properties but it prints all of them fine?

local ui = script.Parent
local Panel = ui.Panel
local Open = ui.Open

local isOpen = false
local fading = false

local Props = {
    ["Frame"] = "BackgroundTransparency",
    ["TextButton"] = {
        "BackgroundTransparency",
        "TextTransparency"
    },
    ["ImageLabel"] = "ImageTransparency",
    ["TextLabel"] = {
        "BackgroundTransparency",
        "TextTransparency"
    }
}

function checkType(ins)
    if ins.ClassName == nil then
        return typeof(ins)
    elseif ins.ClassName ~= nil then
        print(ins.ClassName)
        return ins.ClassName
    end
end

function fadeIn()
    fading = true
    for _, ins in pairs(Panel:GetDescendants()) do
        local typ = checkType(ins)
        if Props[typ] then
            for i = 1, 0, -0.1 do
                wait(0.1)
                if checkType(Props[typ]) == "table" then
                    for _, prop in pairs(Props[typ]) do
                        print(prop)
                        ins[prop] = ins[prop] + i
                    end
                elseif typeof(checkType(Props[typ])) == "string" then
                    print(Props[typ])
                    if typeof(Props[typ]) == "table" then
                        for i, prop in pairs(Props[typ]) do
                            ins[prop[i]] = ins[prop[i]] + i
                        end
                    else
                        ins[Props[typ]] = ins[Props[typ]] + i
                    end
                end
            end
        end
    end
    fading = false
end

function fadeOut()
    fading = true
    for _, ins in pairs(Panel:GetDescendants()) do
        local typ = checkType(ins)
        if Props[typ] then
            for i = 0, 1, 0.1 do
                wait(0.1)
                if checkType(Props[typ]) == "Table" then
                    for _, prop in pairs(Props[typ]) do
                        ins[prop] = ins[prop] + i
                    end
                elseif checkType(Props[typ]) == "String" then
                    ins[Props[typ]] = ins[Props[typ]] + i
                end
            end
        end
    end
    fading = false
end

Open.MouseButton1Click:Connect(function()
    if not fading then
        if isOpen then
            fadeOut()
            isOpen = false
            return
        elseif isOpen == false then
            fadeIn()
            isOpen = true
        end
    end
end)

Answer this question