So I have this TextBox. I want to make it so its size is always the same as its textbounds. I think the way to do it is to convert TextBounds to UDim2, and make it so it's size is that. But TextBounds is 2 numbers, and UDim2 is 4.
--This is what I tried local CodeBox = script.Parent local CodeBox_Size = script.Parent.Size local CodeBox_TextBounds = script.Parent.TextBounds for i=0,math.huge do --infinite loop wait() CodeBox.Size = UDim2.new(CodeBox_TextBounds) end
TextBounds are actually measured in pixels. The offset of UDim2 is also measured in pixels. You can make a UDim2 value, and then insert 0 for the Scale parts and put TextBounds in for the Offset parts.
Update: Didn't realize that you were changing the text. In that case, then you should be assigning your variable inside the loop. Here is the edited script:
--This is what I tried local CodeBox = script.Parent for i=0,math.huge do --infinite loop (Just wondering why is this here?????????????) wait() local CodeBox_Size = script.Parent.Size local CodeBox_TextBounds = script.Parent.TextBounds CodeBox.Size = UDim2.new(0, CodeBox_TextBounds.X, 0, CodeBox_TextBounds.Y) end