Finding all children of "game"

This may be a dumb question, but I need to find all the children of “game”.

For example, referencing game.Workspace leads you to workspace, but what if I just want to search that “game” part. Is that possible?

it is possible but your code will error the second it touches services with priorities above the developers set priority level

1 Like

I need to do this because I don’t want 25 lines of code over and over again to find the children of every single service

What exactly are you trying to achieve by getting the children/descendants of services?

1 Like

Mostly because I tried out a plugin and now everything is infested with crazy things, but I had the idea of making a script to do it and possibly use it for other purposes (like digging deep into folders and models to delete scripts)

Why cant you just revert the games version then?

I can do that, but I just was curious if I could do it via a script. I can close the topic if you wish

You could achieve this by doing a for loop of game:GetDescendants() and wrapping a pcall function so that even if it errors itll continue. Then you’d just have specific naming to search for or properties/classname

Alright, I’ll try that. I’ll mark it as solved (so the mods dont moderate me, i want that clean history!)

Thanks for your help!

1 Like

You can actually use game:GetChildren() without an error, you just have to use pcall if you’re trying to index anything.

local services = {}

for i,v in ipairs(game:GetChildren()) do
	local success, result = pcall(function()
		return v.Name
	end)
	if success then
		table.insert(services, result)
	end
end

print(services)
  ▼  {
                    [1] = "Workspace",
                    [2] = "Run Service",
                    [3] = "GuiService",
                    [4] = "Stats",
                    [5] = "SoundService",
                    [6] = "LogService",
                    [7] = "ContentProvider",
                    [8] = "Instance",
                    [9] = "Instance",
                    [10] = "Chat",
                    [11] = "MarketplaceService",
                    [12] = "Players",
                    [13] = "PointsService",
                    [14] = "AdService",
                    [15] = "NotificationService",
                    [16] = "ReplicatedFirst",
                    [17] = "HttpRbxApiService",
                    [18] = "TweenService",
                    [19] = "MaterialService",
                    [20] = "TextService",
                    [21] = "PermissionsService",
                    [22] = "StarterPlayer",
                    [23] = "StarterPack",
                    [24] = "StarterGui",
                    [25] = "LocalizationService",
                    [26] = "PolicyService",
                    [27] = "Teleport Service",
                    [28] = "JointsService",
                    [29] = "CollectionService",
                    [30] = "PhysicsService",
                    [31] = "BadgeService",
                    [32] = "Geometry",
                    [33] = "FriendService",
                    [34] = "InsertService",
                    [35] = "GamePassService",
                    [36] = "Debris",
                    [37] = "Instance",
                    [38] = "CookiesService",
                    [39] = "GamepadService",
                    [40] = "Instance",
                    [41] = "Instance",
                    [42] = "Instance",
                    [43] = "VRService",
                    [44] = "ContextActionService",
                    [45] = "Instance",
                    [46] = "AssetService",
                    [47] = "TouchInputService",
                    [48] = "Instance",
                    [49] = "AnalyticsService",
                    [50] = "Script Context",
                    [51] = "HttpService",
                    [52] = "FilteredSelection",
                    [53] = "Selection",
                    [54] = "FilteredSelection",
                    [55] = "ServerScriptService",
                    [56] = "ServerStorage",
                    [57] = "ReplicatedStorage",
                    [58] = "ChangeHistoryService",
                    [59] = "Instance",
                    [60] = "ProcessInstancePhysicsService",
                    [61] = "NetworkClient",
                    [62] = "LanguageService",
                    [63] = "HapticService",
                    [64] = "MeshContentProvider",
                    [65] = "Lighting",
                    [66] = "SolidModelContentProvider",
                    [67] = "HSRDataContentProvider",
                    [68] = "Instance",
                    [69] = "FilteredSelection",
                    [70] = "Visit",
                    [71] = "Instance",
                    [72] = "Instance",
                    [73] = "Teams",
                    [74] = "TestService",
                    [75] = "SocialService",
                    [76] = "ProximityPromptService",
                    [77] = "MemStorageService",
                    [78] = "GroupService",
                    [79] = "Instance",
                    [80] = "VirtualInputManager",
                    [81] = "Instance",
                    [82] = "UserService"
                 }  -  Client - LocalScript:12
1 Like

Yeah, was assuming OP wanted to get descendants based off the original query.

1 Like