Hi! I recently started trying to learn about how to create your own chat system so I chose to follow some tutorials. This one to be exact. I've followed every step and double checked everything but the thing is that even though it prints out the texts, it prints them out even if they are profane. And I don't know what I'm doing wrong. I know that there isn't anything wrong with the build in functions (obviously), so it has to be (I'm assuming) the way I use those functions.
I have a remote event in game.ReplicatedStorage
Local script:
--Local script
local textbox = script.Parent
local uis = game:GetService("UserInputService")
local sendMsg = game.ReplicatedStorage:WaitForChild("RemoteEvent")
textbox.FocusLost:Connect(function(text)
sendMsg:FireServer(textbox.Text)
textbox.Text = ""
end)
uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.T then
if textbox:IsFocused() == false then
textbox:CaptureFocus()
end
end
end)
ServerScript:
--ServerScript
local sendMsg = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local textService = game.TextService-- or game:GetService("TextService")
local function filterText(Input,player)
local filteredtext
local success, errorMessage = pcall(function()
filteredtext = textService:FilterStringAsync(Input, player)
end)
if success then
return filteredtext
elseif errorMessage then
print("error: ",errorMessage)
end
return false
end
local function filteredText(filtertext)
local filteredMessage
local success, errorMessage = pcall(function()
filteredMessage = filtertext:GetNonChatStringForBroadcastAsync()
end)
if success then
return filteredMessage
else
print("error: ",errorMessage)
end
return false
end
local function isMessageValid(player, Message)
if Message ~= "" then
local messageObject = filterText(Message, player.UserId)
local filteredMessageObj = ""
filteredMessageObj = filteredText(messageObject)
print(filteredMessageObj)
game.Workspace.Part.SurfaceGui.TextLabel.Text = filteredMessageObj
end
end
sendMsg.OnServerEvent:Connect(isMessageValid)
Any help would be great.

1 comment
Thank you for the information! :)