Filtering TextBox problem

Hello i’m not good at scripting so i got a problem with a board text changer script, i did filtering text thing but it still wont work did i do something wrong in the code?

code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("SendSignal")

--rwor is a Text from a textbox

Event.OnServerEvent:Connect(function(player, rwor, PlayerName, PlayerID, board)
	local est = game:GetService("Chat"):FilterStringForBroadcast(rwor, player)
	if board == "Board" then
		game.Workspace.BOARD1.ewqeqw.Message.Text = est
		game.Workspace.BOARD1.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD1.ewqeqw.Neim.Text = PlayerName
	elseif board == "Board2" then
		game.Workspace.BOARD2.ewqeqw.Message.Text = est
		game.Workspace.BOARD2.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD2.ewqeqw.Neim.Text = PlayerName
	elseif board == "Board3" then
		game.Workspace.BOARD3.ewqeqw.Message.Text = est
		game.Workspace.BOARD3.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD3.ewqeqw.Neim.Text = PlayerName
	end
end)

I finally got solution by @MallocByte
Here fixed code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("SendSignal")

Event.OnServerEvent:Connect(function(player, rwor, PlayerName, PlayerID, board)
	local estp = game:GetService("TextService"):FilterStringAsync(rwor, player.UserId)

	local est = estp:GetNonChatStringForBroadcastAsync()
	if board == "Board" then
		game.Workspace.BOARD1.ewqeqw.Message.Text = est
		game.Workspace.BOARD1.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD1.ewqeqw.Neim.Text = PlayerName
	elseif board == "Board2" then
		game.Workspace.BOARD2.ewqeqw.Message.Text = est
		game.Workspace.BOARD2.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD2.ewqeqw.Neim.Text = PlayerName
	elseif board == "Board3" then
		game.Workspace.BOARD3.ewqeqw.Message.Text = est
		game.Workspace.BOARD3.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD3.ewqeqw.Neim.Text = PlayerName
	end
end)

Thanks for helping

What’s wrong exactly? Is the filtered text not well-filtered or is there an error. The wiki says that :FilterStringForBroadcast() has some limitation compared to :FilterStringAsync(), try this one instead maybe.

Also the script can be easily shortened to something like this

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("SendSignal")

--rwor is a Text from a textbox

Event.OnServerEvent:Connect(function(player, rwor, PlayerName, PlayerID, board)
	local est = game:GetService("Chat"):FilterStringForBroadcast(rwor, player)
    local obj = game.Workspace[string.upper(board)].ewqeqw
	obj.Message.Text = est
	obj.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
	obj.Neim.Text = PlayerName

end)

FilterStringAsync is what you need to use on the server. FilterStringForBroadcast is deprecated for the client side and should not be used on the server.

This is different from ChatService, rather this is newer and is a part of TextService
Cheers

EDIT: The function returns an instance. To get the string, use this on that instance.

Make sure that you have a correct spelling of the word ‘Board’ because you don’t use any string.lower or anything else might be a problem that it doesn’t find correct string and operation stops. I also heard that there were many problems with this FilterStringForBroadcast so try using FilterStringAsync for the server-side. I just read on the wiki that it has to be used on server-side, so make sure you use it.

@MallocByte FilterStringAsync is also deprecated on client-side and it shouldn’t be used anymore there. It has to be used on the server-side like you said, just to mention.

There are two FilterStringAsyncs. The one I referenced is not of ChatService, rather of TextService. That is server sided and should be used.

now its saying “Arguments 3 missing or nil”

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("SendSignal")

Event.OnServerEvent:Connect(function(player, rwor, PlayerName, PlayerID, board)
	local est = game:GetService("TextService"):FilterStringAsync(rwor, player)
	if board == "Board" then
		game.Workspace.BOARD1.ewqeqw.Message.Text = est
		game.Workspace.BOARD1.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD1.ewqeqw.Neim.Text = PlayerName
	elseif board == "Board2" then
		game.Workspace.BOARD2.ewqeqw.Message.Text = est
		game.Workspace.BOARD2.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD2.ewqeqw.Neim.Text = PlayerName
	elseif board == "Board3" then
		game.Workspace.BOARD3.ewqeqw.Message.Text = est
		game.Workspace.BOARD3.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD3.ewqeqw.Neim.Text = PlayerName
	end
end)

It returns an instance, not a string. Do this

local estp = game:GetService("TextService"):FilterStringAsync(rwor, player)

local est = estp:GetNonChatStringForBroadcastAsync()

EDIT: Fixed typo

is there’s something wrong? because i got new error in output when i use your script
“Unable to cast Instance to int64”

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("SendSignal")

Event.OnServerEvent:Connect(function(player, rwor, PlayerName, PlayerID, board)
	local estp = game:GetService("TextService"):FilterStringAsync(rwor, player)

	local est = estp:GetNonChatStringForBroadcastAsync()
	if board == "Board" then
		game.Workspace.BOARD1.ewqeqw.Message.Text = est
		game.Workspace.BOARD1.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD1.ewqeqw.Neim.Text = PlayerName
	elseif board == "Board2" then
		game.Workspace.BOARD2.ewqeqw.Message.Text = est
		game.Workspace.BOARD2.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD2.ewqeqw.Neim.Text = PlayerName
	elseif board == "Board3" then
		game.Workspace.BOARD3.ewqeqw.Message.Text = est
		game.Workspace.BOARD3.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD3.ewqeqw.Neim.Text = PlayerName
	end
end)

It needs to be player.UserId. Right now you are putting in the Player instance, not the int64 UserId

local estp = game:GetService("TextService"):FilterStringAsync(rwor, player.UserId)

FilterStringAsync’s 2nd parameter is supposed to be the userId of the player filtering the text, but you passed the player object itself. Fix:

local estp = game:GetService(“TextService”):FilterStringAsync(rwor, player.UserId)
local est = estp:GetNonChatStringForBroadcastAsync()

I just posted that, must of lagged hehe.

ALSO OP: The FilterStringAsync will by default assume the context is a private chat. However, if it is public, you need to add a 3rd argument for the textContext argument. It needs to be the following Enum: https://developer.roblox.com/en-us/api-reference/enum/TextFilterContext/index.html with it being the PublicChat Enum.

doesnt work, still no tags or something like that

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("SendSignal")

Event.OnServerEvent:Connect(function(player, rwor, PlayerName, PlayerID, board)
	local estp = game:GetService("TextService"):FilterStringAsync(rwor, player.UserId)

	local est = estp:GetNonChatStringForBroadcastAsync()
	if board == "Board" then
		game.Workspace.BOARD1.ewqeqw.Message.Text = est
		game.Workspace.BOARD1.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD1.ewqeqw.Neim.Text = PlayerName
	elseif board == "Board2" then
		game.Workspace.BOARD2.ewqeqw.Message.Text = est
		game.Workspace.BOARD2.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD2.ewqeqw.Neim.Text = PlayerName
	elseif board == "Board3" then
		game.Workspace.BOARD3.ewqeqw.Message.Text = est
		game.Workspace.BOARD3.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
		game.Workspace.BOARD3.ewqeqw.Neim.Text = PlayerName
	end
end)

What error are you getting? Is there an error or is text being set to the billboard.

Text is being set on a SurfaceGui

Try in game, not studio. I don’t think things are filtered in studio.

Oh my god it’s worked, thank you so much, you just saved my life

1 Like

No problem! Have fun :slight_smile:

1 Like