Trying to get billboardgui to scale with size of character

Hey! So I’m making one of those games where you eat blobs to get bigger, but I’m not sure how to scale the billboardGUI that shows the name of the player, size and other things with the size of the character itself. I’m scaling the humanoidRootPart.

This is the hierachy:

Currently, I just put this for when the size changes, but its not accurate:

	script.Parent.HumanoidRootPart.GUI.Size = script.Parent.HumanoidRootPart.Size
	for _,v in pairs(script.Parent.HumanoidRootPart.GUI:GetChildren()) do
		if v.Name ~= "WeldConstraint" then
			v.Size = UDim2.new(v.Size.X.Scale*1.0005,0, v.Size.Y.Scale*1.0005, 0)
		end
	end
	end)

I’m not really experienced with billboardGUI, so I’d appreciate any help :smiley:

1 Like

The Size property of a BillboardGui is a UDim2, however on a BillboardGui the Scale components determine the render size in studs. The Offset components determine the render size in pixels. For example, setting the Size of a BillboardGui to UDim2.fromScale(10, 5), it will always be 10x5 studs, however if you set the Size of a BillboardGui to UDim2.fromOffset(400, 200), it will always be 400x200 pixels.

It’s up to exactly how you’d like the BillboardGui to “scale” with the growing character that would determine which approach you use. If you want to always enforce the BillboardGui is 1 stud bigger than the HumanoidRootPart you could use something like the following line in the code you posted:

local hrpSize = script.Parent.HumanoidRootPart.Size
v.Size = UDim2.fromScale(hrpSize.X + 1, hrpSize.Y + 1)

This works, but I have 3 different GUI’s that have different Y values, and this makes them all the same. I tried to subtract its Y from the hrp’s Y, but it started lagging out.