EDIT: I fixed it as you didn't need to send a player variable when firing a remote event to a server script.
My custom chat gui isn't working. The game is filtering enabled and its always giving this error:
11:07:47.311 - ServerScriptService.ServerChatHandler:9: attempt to concatenate local 'message' (a userdata value)
Local Script:
-- Scripted by LifeInDevelopment
local userInputService = game:GetService('UserInputService')
local replicatedStorage = game:GetService('ReplicatedStorage')
local chatEvent = replicatedStorage:WaitForChild('ChatEvent')
local sendChatMessage = replicatedStorage:WaitForChild('SendChatMessage')
local player = game.Players.LocalPlayer
local gui = script.Parent
local chatFrame = gui:WaitForChild('ChatFrame')
local woodBackground = chatFrame:WaitForChild('WoodBackground')
local chatLabels = chatFrame:WaitForChild('ChatLabels')
local chatBox = gui:WaitForChild('ChatBox')
local chat1 = chatLabels:WaitForChild('Chat1')
local chat2 = chatLabels:WaitForChild('Chat2')
local chat3 = chatLabels:WaitForChild('Chat3')
local chat4 = chatLabels:WaitForChild('Chat4')
local chat5 = chatLabels:WaitForChild('Chat5')
local chat6 = chatLabels:WaitForChild('Chat6')
local chat7 = chatLabels:WaitForChild('Chat7')
local chat8 = chatLabels:WaitForChild('Chat8')
local chat = {chat1, chat2, chat3, chat4, chat5, chat6, chat7, chat8}
local maxMessages = 8
chatBox.FocusLost:connect(function(enterPressed)
if enterPressed then
chatEvent:FireServer(player, chatBox.Text)
addMessage('[' .. player.Name .. ']: ' .. chatBox.Text)
chatBox.Text = "Press '/' to chat"
end
end)
userInputService.InputBegan:connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.Slash then
chatBox:CaptureFocus()
end
end)
sendChatMessage.OnClientEvent:connect(function(filteredString, sender)
print(filteredString)
addMessage('[' .. sender.Name .. ']: ' .. filteredString)
end)
function addMessage(filteredString)
chat1.Text = chat2.Text
chat2.Text = chat3.Text
chat3.Text = chat4.Text
chat4.Text = chat5.Text
chat5.Text = chat6.Text
chat6.Text = chat7.Text
chat7.Text = chat8.Text
chat8.Text = filteredString
end
Server Script:
local replicatedStorage = game:GetService('ReplicatedStorage')
local chatEvent = replicatedStorage:WaitForChild('ChatEvent')
local sendChatMessage = replicatedStorage:WaitForChild('SendChatMessage')
chatEvent.OnServerEvent:connect(function(player, message)
for _, v in pairs (game.Players:GetPlayers()) do
local filteredString = '[' .. player.Name .. ']: ' .. message
if not game:GetService('RunService'):IsStudio() then
print('Not in studio, can filter string')
local filteredString = '[' .. player.Name .. ']: ' .. game.Chat:FilterStringAsync(message, player, v)
end
sendChatMessage:FireClient(v, filteredString)
end
end)

1 comment
That used to mess me up too.