How to find the tallest accessory of the character?

Hi. I am making a billboard GUI that shows player’s health. I need to find the tallest point of the character so I can parent it there, I know there’s a post about it, but they just said to use :GetBoundingBox(), but nothing how to do it. Thanks for any help :slight_smile:

GetBoundingBox() returns two values. You will get a CFrame at the center of the model, and a Vector3 the exact size of the player model and then use the Y value of that to get a position at the very top of the player.

local Character = Player.Character
local CF, Size  = Character:GetBoundingBox()

local TopPoint = CF + Vector3.new(0, Size.Y/2, 0)

Since you want the exact top, and the Cframe is directly in the center, the top will be offset by half of the players height.

Note: I havent tested any of this as I’m on mobile right now but this is the general idea

Edit: yes, you do need to remember that accessories can be much larger than their Handle. You may need to add an additional offset, for example another stud upwards, to account for this.

2 Likes

This may be tough to do since a lot of the older accessories are Meshes in Parts so their visible size doesn’t really fit into the Part’s BoundingBox so when the Accessory is attached to your Character the addition of that BoundingBox to your Character’s won’t align.

Best of luck to you though.

1 Like

How would I go about getting the tallest part instead of the ‘TopPoint’? Thanks for replying! I really appreciate it!

You can use a for loop and go through every accessory, checking its Y value against the previous one. If there arent any accessories at all, just use the head position.

local tallest = vector3.new(0,-500,0)

for _, hat in pairs(Character:GetChildren()) do
  if hat:IsA("Accoutrement") then
    if hat.Handle.Position.Y > tallest.Y then
        tallest = hat.Handle.Position
    end
  end
end

Then you will be left with the tallest position on the player. This is a simple version and you might want to save the actual accessory, which is also easy, you can store that in the variable as well.

I used Accoutrement because that works for both legacy hats and accessories

You could compare the Y axis of the accessories of the player and get the highest one. (@Blokhampster34 wrote it already)

What is “Accoutrement” you’ve typed in the code? Sorry If I am asking too many questions.

Accoutrement is just another way of saying accessory. It basically means you can use accessories or the legacy hat class
It will work if you replace it with Accessory too

Oh, alright, thanks for your help! :smiley:

1 Like