I'm using GetChildren() on a character in an attempt to find their hats, but GetChildren() doesn't seem to include hats. Any workaround for this?
The Character does contain hats. Note that the hats are Hat
or Accoutrement objects, which include the "Handle"
Part only as a child.
Something like this will do the trick:
function getHats( character ) local children = character:GetChildren(); local hats = {}; for _, child in pairs(children) do if child:IsA("Accoutrement") then table.insert( hats, child ); end end return hats; end
The part with the mesh will be called Handle
inside.
It's possible that the Character will not be fully loaded when you initially search for hats. It might be a good idea to wait a moment to be sure. Off the top of my head I cannot think of any signal to indicate that the Character is finished loading but perhaps someone else can remember one.
Locked by OniiCh_n, M39a9am3R, and Shawnyg
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?