this code is meant to cap the size of a textbox, so when it hits the max size limit, it stops auto scaling, and when it goes below, it starts auto scaling again
the problem is that when you hit the max size limit, it oscillates between auto scale and being the correct max size.
i might be completely dumb and this is a simple fix, but idk
Code:
local Input = script.Parent
local InputBox = Input.InputBox
local InputName = Input.InputName
local signal
local function checkSize()
local nameWidth = InputName.AbsoluteSize.X
local totalWidth = Input.AbsoluteSize.X
local maxWidth = totalWidth - nameWidth - 20
if InputBox.AbsoluteSize.X > maxWidth then
InputBox.Size = UDim2.new(InputBox.Size.X.Scale, maxWidth, InputBox.Size.Y.Scale, InputBox.Size.Y.Offset)
InputBox.AutomaticSize = Enum.AutomaticSize.None
elseif InputBox.AbsoluteSize.X < maxWidth then
InputBox.Size = UDim2.new(InputBox.Size.X.Scale, 41, InputBox.Size.Y.Scale, InputBox.Size.Y.Offset)
InputBox.AutomaticSize = Enum.AutomaticSize.X
end
end
signal = InputBox:GetPropertyChangedSignal("AbsoluteSize"):Connect(checkSize)
also heres the element if you want to test yourself
Input.rbxm (9.6 KB)