I’m trying to make a system were the frames size changes dependant on the text’s size as a string.
Any help will be appreciated.
I’m trying to make a system were the frames size changes dependant on the text’s size as a string.
Any help will be appreciated.
Maybe this could help?
https://developer.roblox.com/en-us/api-reference/property/GuiObject/AutomaticSize
local constant = 1.2
TextLabel:GetPropertyChangedSignal(‘TextSize’):Connect(function()
local Size = TextLabel.TextSize * constant
Frame.Size = UDim2.new(Size, 0, Size, 0)
end)
Is this similar to what you want? I don’t think I understand
I’m trying to get it to were lets say the default text is “Hello!” and the text changes to “Hello World!” the frame’s size will change too.
So you mean you want the frame size to change depending on the length of the string. In that case, you can do something similar to what I did above:
local constant = 1.2
TextLabel:GetPropertyChangedSignal(‘Text’):Connect(function()
local Size = string.len(TextLabel.Text) * constant
Frame.Size = UDim2.new(Size, 0, Size, 0)
end)
This way, whenever the text of the textlabel changes, the frame size will update using the number of characters in the string.
Sorta works, when the text is e.g ‘$900K’ then it works perfectly but when the text is ‘$1K’ then it cuts the text of a bit
You have to play around with the constant variable to fix it. Increase it a bit. Maybe try 1.25 or 1.5
Works thanks so much, good to know and to use in the future and currently.