Hello developers!
I need some help with a script that filters text. I took a script from the Text and Chat Filtering page on the Developer Hub. If anybody can help me or tell me why my script isn’t filtering text then I would be very happy!
Scripts
Script
-- Service
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextService = game:GetService("TextService")
local ShoutCommandEvent = ReplicatedStorage:WaitForChild("AdminEvent").ShoutCommandEvent
local ShoutClientCommandEvent = ReplicatedStorage:WaitForChild("AdminEvent").ShoutClientCommandEvent
--
ShoutCommandEvent.OnServerEvent:Connect(function(player, ShoutText)
local filteredTextResult
local success, errorMessage = pcall(function()
filteredTextResult = TextService:FilterStringAsync(ShoutText, player.UserId)
end)
if success then
ShoutClientCommandEvent:FireAllClients(player, ShoutText)
elseif not success then
warn(errorMessage)
end
end)
Local Script
-- Service
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ShoutCommandEvent = ReplicatedStorage:WaitForChild("AdminEvent").ShoutCommandEvent
local ShoutClientCommandEvent = ReplicatedStorage:WaitForChild("AdminEvent").ShoutClientCommandEvent
-- Locals
local ShoutButton = script.Parent.Parent.Background.ServerPlayerCommands.ServerShout.ShoutButton
local ShoutText = script.Parent.Parent.Background.ServerPlayerCommands.ServerShout.TextBox
local Text = script.Parent.Parent.ShoutFrame.TextLabel
--
ShoutButton.MouseButton1Click:Connect(function()
ShoutCommandEvent:FireServer(ShoutText.Text)
end)
ShoutClientCommandEvent.OnClientEvent:Connect(function(player, FilterText)
Text.Text = FilterText
end)