I am attempting to make custom bubble chat that matches my game but for some reason anytime I use GetTextSize it returns a size to small for the passed text to fit in. I get no erros. As you can see in the output its not the msg as it prints out a correct string but in the image you can see it cuts off large parts of the text.
CODE:
local Character = {}
Character.__index = Character
local StatsMananger = require(script.Parent.StatsManager)
local ChatService = game:GetService("Chat")
local TextService = game:GetService("TextService")
local HttpService = game:GetService("HttpService")
local Objects = {}
function Character.new(player)
local self = setmetatable({}, Character)
player:LoadCharacter()
local messages = {}
self.Player = player
self.Character = player.Character or player.CharacterAdded:Wait()
local ChatPart = Instance.new("Part")
ChatPart.Name = "Head"
ChatPart.Anchored = false
ChatPart.Parent = self.Character
ChatPart.Transparency = 1
ChatPart.Position = self.Character.HumanoidRootPart.Position + Vector3.new(0,3.5,0)
game:GetService("ServerStorage").UIElements.Messages.PlayerMessage:Clone().Parent = ChatPart
player.Chatted:Connect(function(msg)
local msg = ChatService:FilterStringForBroadcast(msg, player)
print(msg)
local messageFrame = game:GetService("ServerStorage").UIElements.Messages.MessageFrame:Clone()
messageFrame.Parent = ChatPart.PlayerMessage.Main
messageFrame.TextLabel.Text = msg
local size = TextService:GetTextSize(msg, messageFrame.TextLabel.TextSize, Enum.Font.Cartoon, messageFrame.AbsoluteSize)
messageFrame.Size = UDim2.new(0, size.X, 0, size.Y)
messageFrame.TextLabel.Size = UDim2.new(0, size.X, 0, size.Y)
end)
local Weld = Instance.new("WeldConstraint")
Weld.Parent = self.Character.HumanoidRootPart
Weld.Part0 = self.Character.HumanoidRootPart
Weld.Part1 = ChatPart
Objects[player.Name] = self
return Objects[player.Name]
end
function Character:getCharacter(player)
return Objects[player.Name]
end
function Character:destroy()
Objects[self.Player.Name] = nil
end
return Character