Roblox chat filter!

hello hello hello,

i have made a chat system but im failing to figure out a way to filter a message before sending it. not sure if this makes any sense. in the script below i want the local FilteredMessage to actually return a filtered message, not just the message

local Event = game:GetService("ReplicatedStorage").Chat_SendMessage
local Tween = game:GetService("TweenService")

Event.OnServerEvent:Connect(function(Player, Message)
	for increment , selectedPlayer in pairs(game:GetService("Players"):GetPlayers()) do
		local Chat = selectedPlayer.PlayerGui.Chat.MessageClip.Template:Clone()
		local FilteredMessage = Message
		Chat.Parent = selectedPlayer.PlayerGui.Chat.MessageClip
		Chat.Text = [[<font color="#55aaff">[]] .. Player.Name .. "]:" .. "</font> " .. FilteredMessage
		Chat.Visible = true
		Tween:Create(Chat, TweenInfo.new(0.3), {TextTransparency = 0}):Play()
		Tween:Create(Chat, TweenInfo.new(0.3), {TextStrokeTransparency = 0.8}):Play()
		wait(25)
		Tween:Create(Chat, TweenInfo.new(0.3), {TextTransparency = 1}):Play()
		Tween:Create(Chat, TweenInfo.new(0.3), {TextStrokeTransparency = 1}):Play()
		wait(0.5)
		Chat:Destroy()
	end
end)
1 Like
3 Likes

i have used this and implimented it, however there is an error…

image

it isnt showing the filtered string

FIXED!!

local Event = game:GetService("ReplicatedStorage").Chat_SendMessage
local Tween = game:GetService("TweenService")
local Text = game:GetService("TextService")

Event.OnServerEvent:Connect(function(Player, Message)
	for increment, selectedPlayer in pairs(game:GetService("Players"):GetPlayers()) do
		local Chat = selectedPlayer.PlayerGui.Chat.MessageClip.Template:Clone()
		local FilteredMessage = Text:FilterStringAsync(Message, Player.UserId, Enum.TextFilterContext.PublicChat)

		local success, filteredText = pcall(function()
			return FilteredMessage:GetChatForUserAsync(Player.UserId)
		end)

		if success then
			Chat.Parent = selectedPlayer.PlayerGui.Chat.MessageClip
			Chat.Text = "<font color=\"#55aaff\">[" .. tostring(Player.Name) .. "]:</font> " .. tostring(filteredText)
			Chat.Visible = true
			Tween:Create(Chat, TweenInfo.new(0.3), {TextTransparency = 0}):Play()
			Tween:Create(Chat, TweenInfo.new(0.3), {TextStrokeTransparency = 0.8}):Play()
			wait(25)
			Tween:Create(Chat, TweenInfo.new(0.3), {TextTransparency = 1}):Play()
			Tween:Create(Chat, TweenInfo.new(0.3), {TextStrokeTransparency = 1}):Play()
			wait(0.5)
			Chat:Destroy()
		else
			warn("Text filtering error:", filteredText)
		end
	end
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.