For some reason, every time I run studios, it crashed because I added a TextFits if Statment in. Any way I could fix this?
ChatBar.Changed:connect(function() local YSize = 0 ChatBar.Size = UDim2.new(1, -6, 0, ChatSettings.ChatFontSize + 2) if ChatBar.TextFits == false then YSize = YSize + 1 end ChatBar.Size = UDim2.new(1, -6, 0, (YSize * ChatSettings.ChatFontSize) + ChatSettings.ChatFontSize + 2) end)
You have a Changed event on the TextBox. Basically what that means, is anytime a property of the TextBox is changed, that event will fire
, which includes Size. You've gotten yourself into an eternal loop since TextBounds
will change once text is entered, and due to your code, once the Changed event fires, it'll change the Chatbar's size, which in turn fires the Changed event again, and forever on. To fix this issue, instead of using the Changed event, consider using the InputBegan event.