Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Scanning the workspace for all decal/sound IDs?

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

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.