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

Scanning the workspace for all decal/sound IDs?

Asked by 8 years ago

How would I go about scanning the entire workspace to find every ID of every sound, decal, texture, etc and put it in a table? I want to make a preloader but I dont want to have to manually list out every ID the game, that would take forever. I have the preloader/GUI part done, I just would really like to have a system of automatically finding the IDs.

1 answer

Log in to vote
1
Answered by 8 years ago

I had some fun creating this but this will only find assets in the chkItms list and will also not check for assets in scripts.

Take a look at this, you may be able to add more code to check scripts assets, Click here

local chkItms = {
    --[object type] = [ value to be returned]
    ["Sound"] = "SoundId"
}



function scan(itm) 
    for i,v in pairs(itm:GetChildren()) do -- gets all children of the object to scan
        local res, val = chkType(v)  -- check the type against the list 
        if res then print("item:- " .. tostring(v) .. " HasAsset:- " .. val) end -- compares the result     
        scan(v) -- scans all of the parents childs as well creating a loop scan
    end
end

function chkType(itm)
    for i,v in pairs(chkItms) do
        if itm:IsA(i) then -- chack all items  for type
            return true, itm[v] -- returns its value e.g. SoundId
        end
    end
    return false, nil
end


wait(3) -- wait for character to load
scan(game.Workspace) -- scan the workspace

Add a comment if you need help understanding this script as its a bit complex. Hope this helps.

Ad

Answer this question