Textbox sign is not filtering the text (msg)

when the player writes a message in the textbox within the screenGui, the message appears in the sign. But the problem is the msg is not filtering

could someone help me filter this message?

-- LOCAL SCRIPT --

local player = game.Players.LocalPlayer

local TextMsg = script.Parent.CreateMsg:WaitForChild("TextMsg")

TextMsg.Changed:Connect(function()
	if player.Character:FindFirstChild("Sign") then
		player.Character["Sign"]:WaitForChild("UpdateSign"):FireServer(TextMsg.Text)
	end
end)

-- SERVER SCRIPT--

local chat = game:GetService("Chat")

script.Parent.Unequipped:Connect(function()
	script.Parent.SignPart.SurfaceGui.TextLabel.Text = ""
end)

script.Parent.UpdateSign.OnServerEvent:Connect(function(player,msg)
	if player.Character:FindFirstChild("Sign") then
		
		local fithered
		local success, errorMessage = pcall(function()
			fithered = chat:FilterStringAsync(msg,player,player)
		end)
		
		script.Parent.SignPart.SurfaceGui.TextLabel.Text = fithered
	end
end)

Screenshot_1

fireserver with “TextMsg” u can get the TextMsg.Text in the serverscript too!

I’d recommend using TextService. It would look something like this:

local TS = game:GetService(“TextService”)

local success, err = pcall(function()
    filtered = TS:FilterStringAsync(msg, player.UserId)
    filteredc = filtered:GetNonChatStringForBroadcastAsync()
end)

if success then
    script.Parent.SignPart.SurfaceGui.TextLabel.Text = filteredc
else
    print(err)
end

note that filtering only works in game, not studio

1 Like