How to fix the ChatBar


#1

Recently there were changes to text layout which broke the ChatBar in a couple of my games. I’ve had to fix it twice, and seen that others are experiencing the same issues.

Note: This glitch only happens to people with custom chat systems. It appears that the ‘ChatBar’ script was updated, somehow causing old scripts to not function properly. All we’re doing is taking the new ChatBar script and replacing the old one with it.

Picture of the glitch:

Here I will tell you how to fix it:

  1. Open both your broken game, and an empty baseplate
    note, you can skip steps 2 & 3 if you just download the script from ChatBar.rbxm (6.9 KB)

  2. Use Play Solo on the empty baseplate

  3. Go to Chat > ChatScript > ChatMain and copy the script called ‘ChatBar’
    image

  4. Put the ChatBar script into the same location in your broken game, and remove the one that was already there.

If you have implemented a custom chatbar style incorrectly, that style may be removed, so back up the old script first to enable you to port that across.


Chat TextBox too large
#2

If you modify the ChatBar script in any way this is the only change you have to make to the ChatBar script:

Add the measureSize function and modify the CalculateSize function as follows:

local function measureSize(textObj)
    return TextService:GetTextSize(
        textObj.Text,
        textObj.TextSize,
        textObj.Font,
        Vector2.new(textObj.AbsoluteSize.X, 10000)
        )
end

function methods:CalculateSize()
    if self.CalculatingSizeLock then
        return
    end
    self.CalculatingSizeLock = true
    local textSize = nil
    local bounds = nil
    if self:IsFocused() or self.TextBox.Text ~= "" then
        textSize = self.TextBox.TextSize
        bounds = measureSize(self.TextBox).Y
    else
        textSize = self.TextLabel.TextSize
        bounds = measureSize(self.TextLabel).Y
    end
    local newTargetYSize = bounds - textSize
    if (self.TargetYSize ~= newTargetYSize) then
        self.TargetYSize = newTargetYSize
        self:TweenToTargetYSize()
    end
    self.CalculatingSizeLock = false
end

#3

Thanks!


#5

This is completely unrelated to the new PlayerScripts, it just happens that a change to text layout was made the same week. I just want to point that out so we don’t have people reverting to old PlayerScripts because of unrelated Chat system issues.


#6

Oh sorry, I’ll amend the OP, I just assumed that chat changes were rolled out as part of the new player scripts


#7

thank :smiley:


#8

And define TextService too.

local TextService = game:GetService("TextService")