How to get descendants of all players in workspace? Like humanoid, pants, shirt, parts, etc.
Here's the code for you:
for _,player in pairs(game.Players:GetPlayers()) do local playerCharacter = player.Character--Their Character in Workspace for _,playerDescendant in pairs(playerCharacter:GetChildren()) do --Code for the descendants --something something end end
do this:
local assets = {} for _, player in ipairs(game.Players:GetPlayers()) do table.insert(assets, player.UserId) assets[player.UserId] = player.Character:GetDescendants() wait() end
game.Players:GetPlayers() to get players, insert the userid into the table, then the userid value is a table containing all the contents of player:GetDescendants() I added a wait() function to prevent server crashing. Btw, you can print the assets by doing
for playerUserId, instances in pairs(assets) do for _, instanceNames in ipairs(instances) do print(instanceNames) end wait() end
Closed as Not Constructive by Ziffixture
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?