for _, brick in pairs (game.Workspace:GetChildren()) do if brick.Name == "Wall" then print("found the wall") end end
This script checks for the children of workspace for a part named "Wall". However "Wall" is in a model which is a child of workspace...how would I get the wall part because the lines above only seem to search through Workspace and not the models inside of it.
I'm assuming you want to scan the entire file structure of workspace. You need to create a function that scans a given table for the object you want. That function will call itself on every object it finds to scan its children and so on. This is the general idea:
function scan(table) for _, v in pairs (table) do print(v) scan(v:GetChildren()) end end scan(game.Workspace:GetChildren())