It was related, but okay. Try this.
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
local colors = {'Brown'}
local convTable = {
[":P"] = "tongueEmojiHere",
[":)"] = "smileEmojiHere",
-- etc
}
math.randomseed(os.time())
math.random()
math.random()
math.random()
math.random()
local player = game.Players.LocalPlayer
local nameColor = BrickColor.new(colors[math.random(1, #colors)]).Color
local messageColor = BrickColor.new('Institutional white').Color
local messageBox = script.Parent:WaitForChild('InputFrame'):FindFirstChild('MessageBox')
local UIS = game:GetService('UserInputService')
local event = game:GetService('ReplicatedStorage'):WaitForChild('Chatted')
if player.Name == 'astrelly' then
nameColor = BrickColor.new('Gold').Color
end
function onInput(Input, GPE)
if GPE then return end
if Input.KeyCode == Enum.KeyCode.Slash then
messageBox:CaptureFocus()
end
end
function onFocus()
if messageBox.Text == 'Press \'/\' to type a message...' then
messageBox.Text = ''
end
end
function onFocusLost(EnterPressed)
if EnterPressed then
if messageBox.Text ~= '' then
event:FireServer(nameColor, messageBox.Text, messageColor)
messageBox.Text = 'Press \'/\' to type a message...'
else
messageBox.Text = 'Press \'/\' to type a message...'
end
else
if messageBox.Text == '' then
messageBox.Text = 'Press \'/\' to type a message...'
end
end
end
function addLine(message, Label)
local chatBox = script.Parent:FindFirstChild('Frame')
local newMessage = Instance.new('Frame', chatBox)
newMessage.Size = UDim2.new(1, -10, 0, 20)
newMessage.Position = UDim2.new(0, 5, 1, -25)
newMessage.BackgroundTransparency = 1
newMessage.ClipsDescendants = true
local lineMessage = ''
while Label.TextFits == false do
lineMessage = string.sub(message, -1) .. lineMessage
message = string.sub(message, 1, string.len(message) - 1)
Label.Text = message
end
for _, oldMessage in pairs (chatBox:GetChildren()) do
if oldMessage ~= newMessage then
oldMessage.Position = oldMessage.Position + UDim2.new(0, 0, 0, -newMessage.AbsoluteSize.Y + 5)
end
end
local messageLabel = Instance.new('TextLabel', newMessage)
messageLabel.BackgroundTransparency = 1
messageLabel.Font = 'Cartoon'
messageLabel.TextColor3 = messageColor
messageLabel.FontSize = 'Size18'
messageLabel.TextXAlignment = 'Left'
messageLabel.TextStrokeTransparency = 0
messageLabel.TextStrokeColor3 = Color3.fromRGB(102, 102, 102)
for input,emoji in next, convTable do
messageLabel.Text = message:gsub(input, emoji)
end
messageLabel.Size = UDim2.new(1, -10, 0, 20)
messageLabel.Position = UDim2.new(0, 5, 0, 0)
local LineTag = Instance.new('StringValue', messageLabel.Parent)
LineTag.Name = 'LineTag'
local LineTag2 =Instance.new('StringValue', Label.Parent)
LineTag2.Name = 'LineTag'
if messageLabel.TextFits ~= true then
addLine(lineMessage, messageLabel)
print('addingling')
else
for _, oldMessage in pairs (chatBox:GetChildren()) do
if not oldMessage:FindFirstChild('LineTag') then
oldMessage.Position = oldMessage.Position + UDim2.new(0, 0, 0, -newMessage.AbsoluteSize.Y + 5)
end
end
end
LineTag:Destroy()
LineTag2:Destroy()
end
function onEvent(sender, nameColor, message, messageColor)
local chatBox = script.Parent:FindFirstChild('Frame')
local newMessage = Instance.new('Frame', chatBox)
newMessage.Size = UDim2.new(1, -10, 0, 20)
newMessage.Position = UDim2.new(0, 5, 1, -25)
newMessage.BackgroundTransparency = 1
newMessage.ClipsDescendants = true
local nameLabel = Instance.new('TextLabel', newMessage)
nameLabel.BackgroundTransparency = 1
nameLabel.Font = 'Cartoon'
nameLabel.TextColor3 = nameColor
nameLabel.FontSize = 'Size18'
nameLabel.TextXAlignment = 'Left'
nameLabel.Text = '[' .. sender.Name .. ']:'
nameLabel.Size = UDim2.new(0, nameLabel.TextBounds.X + 5, 0, 20)
nameLabel.TextStrokeTransparency = 1
local messageLabel = Instance.new('TextLabel', newMessage)
messageLabel.BackgroundTransparency = 1
messageLabel.Font = 'Cartoon'
messageLabel.TextColor3 = messageColor
messageLabel.FontSize = 'Size18'
messageLabel.TextXAlignment = 'Left'
for input,emoji in next, convTable do -- replace text with emojis
messageLabel.Text = message:gsub(input, emoji)
end
messageLabel.Text = message
messageLabel.Size = UDim2.new(1, -nameLabel.AbsoluteSize.X, 0, 20)
messageLabel.Position = nameLabel.Position + UDim2.new(0, nameLabel.AbsoluteSize.X, 0, 0)
messageLabel.TextStrokeTransparency = 0
messageLabel.TextStrokeColor3 = Color3.fromRGB(102, 102, 102)
if messageLabel.TextFits ~= true then
addLine(message, messageLabel)
else
for _, oldMessage in pairs (chatBox:GetChildren()) do
if oldMessage ~= newMessage then
oldMessage.Position = oldMessage.Position + UDim2.new(0, 0, 0, -newMessage.AbsoluteSize.Y + 5)
end
end
end
end
UIS.InputBegan:connect(onInput)
event.OnClientEvent:connect(onEvent)
messageBox.Focused:connect(onFocus)
messageBox.FocusLost:connect(onFocusLost)