"TextBounds.X" property staying at 0 on mobile

Hey,

I’m currently trying to scale a text box based on how much text there is in frame. I know there is a property within Textboxes that allows for the box to be scaled. Only issue is that I want there to be a small space between the start of the background and start of the text, same with the end.

My issue is with scaling this on mobile. It just doesn’t work. Anything typed into the box, will always result with the TextBounds.X property being 0.

I don’t see any way that I could achieve this and still have the textbox scale correctly.


I have a basic text box at Position - 0.5,0,0.5,0, and Anchorpoint - 0.5,0.5. The code look like this.

local TextBox = script.Parent
local BorderXSize = 5
local BorderYSize = 5

TextBox:GetPropertyChangedSignal("Text"):Connect(function()
	local ts = TextBox.TextBounds.X
	local x = ts + BorderXSize * 2
	local y = TextBox.TextSize + BorderYSize * 2
	TextBox.Size = UDim2.new(0,x,0,y)
	print("Text Size - "..ts)
	print("UI Size X - "..x)
	print("UI Size X - "..y)
	print(" ")
end)