Hello, my place has a tag game to purchase a tag, but there's a problem, the chat message breaks if i use a different font on another tag, this happens
This is what i'm doing to make the tag with the different font
local tagText = tag.TagText or "???"
local tagfont = tag.TagFont or BaseMessage.Font
local formatTagText = string.format("[%s] ", tagText)
local label = util:AddTagLabelToBaseMessage(BaseMessage, tagColor, formatTagText,tagfont)
Now this is what i do in Util to add a font to it
function methods:AddTagLabelToBaseMessage(BaseMessage, tagColor, formatTagText,fnt)
if not fnt then
fnt=BaseMessage.Font
end
local tagNameSize = self:GetStringTextBounds(formatTagText, fnt, BaseMessage.TextSize)
local TagLabel = self:GetFromObjectPool("TextLabel")
TagLabel.Selectable = false
TagLabel.Size = UDim2.new(0, tagNameSize.X, 0, tagNameSize.Y)
TagLabel.Position = UDim2.new(0, 0, 0, 0)
TagLabel.BackgroundTransparency = 1
TagLabel.Font = fnt
TagLabel.TextSize = BaseMessage.TextSize
TagLabel.TextXAlignment = BaseMessage.TextXAlignment
TagLabel.TextYAlignment = BaseMessage.TextYAlignment
TagLabel.TextTransparency = BaseMessage.TextTransparency
TagLabel.TextStrokeTransparency = BaseMessage.TextStrokeTransparency
TagLabel.TextColor3 = tagColor
TagLabel.Text = formatTagText
TagLabel.Visible = true
TagLabel.Parent = BaseMessage
return TagLabel
end
and GetStringTextBounds here
function methods:GetNumberOfSpaces(str, font, textSize)
local strSize --define the variable in a scope that can be
--accessed by later lines of code
if typeof(str)=="string" then --is it a string?
--if so, treat it like a string.
strSize = self:GetStringTextBounds(str, font, textSize)
elseif typeof(str)=="Instance" then --or is it an icon?
--if so, we can just use the label's AbsoluteSize property.
strSize = str.AbsoluteSize
end
local singleSpaceSize = self:GetStringTextBounds(" ", font, textSize)
return math.ceil(strSize.X / singleSpaceSize.X)
end
How can i fix this so it's positioned correctly?
PS: the roblox place is here
