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

My get children script won't work?

Asked by
Mr1Vgy 30
9 years ago

I have this script, it is supposed to get the children of a model in the player, and then take the names of the children and turn them into a variable, and then print the variable. It sort of works, but it will only get the names of 3 children. Can anyone help?

game.Players.PlayerRemoving:connect(function(plr)
    local items = plr.items:Clone()
    items.Parent = game.ServerStorage
    items.Name = plr.Name.." items"
    local saveItems = plr.Name..": "
    local getItems = items:GetChildren()
    for i, v in pairs(items:getChildren())do
        saveItems = saveItems..(v.Name).." + "
        print(saveItems)
    end
    print(saveItems.."!!!")
end)
0
Which three children? Why do you expect it to get more? Can you show the hierarchy? (e.g., screenshot or type it out) BlueTaslem 18071 — 9y
0
This should work, unless you're attempting to print names of children of children inside the model, in that case you'll need to use recursion. Also I suggest making a table full of all the names then using table.concat, or unpack to print them all. Goulstem 8144 — 9y
0
Maybe the model is being removed as the player leaves the game, so some of the parts are missing when the script gets to them. Discern 1007 — 9y

Answer this question