Hope this is what you wanted put this in in TextBox
local TS = game:GetService("TextService")
local e = script.Parent
e.Changed:Connect(function()
local a = TS:GetTextSize(e.Text,e.TextSize,e.Font,Vector2.new(200,300))
e.Size = UDim2.new(0,a.X,0,a.Y)
end)
More documentation on this parameter is requested, please.
local text = "Hello Roblox"
local a1 = TS:GetTextSize("Hello Roblox", 8, Enum.Font.Legacy, Vector2.new(300,100)) -- 71,12
local a2 = TS:GetTextSize("Hello Roblox", 8, Enum.Font.Legacy, Vector2.new(260,122)) -- 71,12
local a3 = TS:GetTextSize("Hello Roblox", 8, Enum.Font.Legacy, Vector2.new(10,10)) -- 10,12
local a4 = TS:GetTextSize("Hello Roblox", 8, Enum.Font.Legacy, Vector2.new(0,0)) -- 71,12
The (0,0) input vector actually came from Vector2.new(e.AbsoluteSize), which, in hindsight I’d rather parameterise as (btn.AbsoluteSize.X, btn.AbsoluteSize.Y), but I can’t yet pretend to understand the significance of this final parameter.