0

If you have seen this post of mine, then you probably would see a backstory on this. I am making a game in Roblox, and I have a question on how I can make an attribute of an instance part of a code. To make it more clear, here is an example:

local part = script.Parent
local folder = part:GetAttribute("Viewing folder")
local data = "This folder does exist: " + tostring(script.Parent.Parent.(the attribute folder name goes here))

print(data)

My question is how do you use say an attribute or string and add it as part of a path or code.

For my use I'm using it for this:

local tycoon = script.Parent.Parent
local folders = tycoon.Button:GetAttribute("Unlockable_folder")

local function onPartTouched(otherPart)
    local partParent = otherPart.Parent


    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
    if humanoid then
        if tostring(otherPart.Parent) == tycoon:GetAttribute("Owner") then
            print("touched")
            local partsWithAttribute = {}
            local folder = script.Parent.Parent.(folder) -- here is the part that I am confused about

            for i,part in ipairs(folder:GetChildren()) do
                if part:GetAttribute('Unlock_ID') == "1" then
                    table.insert(partsWithAttribute,part)
                end
            end
            for i in ipairs(partsWithAttribute) do
                -- code to unlock the objects in table
            end
        end
        
    end
end

0 Answers0