I couldn’t really find much on this so I decided to try and figure it out myself, I just wondered if there was a better way to do it.
Basically I want to have TextScaled on but prevent people writing so much that the text size decreases, this is for use on a chat field.
The solution I have is to use a changed listener that detects when the TextBounds Y scale changes and then replacing it with the last known “safe” string, here is that code:
As no one has offered an alternative I fixed up the code and prevented resizing breaking the code, here is that for anyone wanting a solution:
local NormalY = Input_Field.TextBounds.Y
local SafeText = nil
Input_Field:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
NormalY = Input_Field.TextBounds.Y
end)
Input_Field:GetPropertyChangedSignal("Text"):Connect(function()
if Input_Field.TextBounds.Y ~= NormalY then
print("Too much text")
Input_Field.Text = SafeText
else
SafeText = Input_Field.Text
end
end)