Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to Create a Max Size Limit for a Billboard GUI?

I made a health bar for a base (it hovers above the center of it) that scales when you zoom out. Everything works fine except when you zoom in enough, the health bar gets very large and covers up the sky. I couldn't find the property for a max size limit so I tried changing it through a script. Here's my code:

function config()
	local healthbar = script.Parent
	healthbar.DistanceLowerLimit = 500
end

config()

I attempted to use DistanceLowerLimit to set a max size when you zoom in close enough, but I probably used it wrong as it isn't working.

Here's the documentation for it: https://developer.roblox.com/en-us/api-reference/property/BillboardGui/DistanceLowerLimit

Please tell me how to use it properly (or if I should use a different approach). I would really appreciate any help since I just started learning Lua and Roblox Studio :)

3 comments

0

I believe you just need to use DistanceUpperLimit instead of DistanceLowerLimit.

0

It's not working ... still no effect.

1 answer

The problem here is likely that the BillboardGuis size property is set using offset values rather than scale values. If you look at the size property of the BillboardGui in the explorer you will see something like this Size: {0, 200},{0, 100} This is the GUIs UDim2 size property. UDim2 is just a coordinate type for GUI elements that allows you to position things using a scale and offset value. The scale value of a UDim2 coordinate is essentially the fraction of the viewport being taken up by the element. The offset value, on the other hand, is the absolute size in pixels of the GUI element.

That being said, if you set the BillboardGui's offset size, it will always remain that size no matter how far away you are from the GUI. If you set only the scale size, however, it will remain the same relative size no matter the distance you are from.

TLDR: Set the GUIs scale size, not offset size (i.e UDim2.new(7, 0, 0.8, 0) looks like a health bar)

1 comment

0

I've already set it to scale previously which didn't work. I want it to keep scaling until you zoom in enough, then I want it to keep it's absolute size (not relative) constant.

This discussion is preserved as it was. New answers, comments, and votes are closed.