Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make FilterStringAsync work in this naming GUI?

Hello! My game has recently been closed for moderation as we have a naming GUI without a filter, I've been trying to get FilterStringAsync to work but I can only get it working for a custom chat and not for typing names into a gui for a billboardgui. This is the GUI script;

local Detect = script.Parent.FocusLost
Detect:connect(function()
	local player1 = game.Players.LocalPlayer
	if script.Parent.Text ~= "" then
		player1.leaderstats.Character.Value = script.Parent.Parent.PlayerName.Text
		player1.Character.Head.BillboardGui.MainFrame.PlayerLabel.Text =(script.Parent.Text)
		player1.Character.Head.BillboardGui.MainFrame.PlayerName.Text = player1.Name
	end
end)

I've tried using the FilterStringAsync unsuccessfully and need help. I'm struggling and would just like my game back, thankyou

1 answer

Before I answer your question, read up on this ROBLOX wiki post.

What Is FilterStringAsync?

According to the ROBLOX Wiki, FilterStringAsync is a built-in function that:

Filters a string being sent to playerTo from playerFrom with filtering that is appropriate to the given player's account settings. This function should be used any time a user can enter custom text in any context.

Based upon this information, FilterStringAsync is a function that allows us to filter strings just as they would be in the default ROBLOX chat. This can be used to hashtag words that ROBLOX wouldn't normally allow.

How do we use it?

FilterStringAsync takes 3 arguments: string stringToFilter Player playerFrom and Player playerto

(These arguments are pretty self-explanatory, so I won't waste time explaining them).

Based on this information, we can use the function like so:

local PlayerYouWantToSendThisTo = game:GetService("Players"):FindFirstChild("Player2")
game:GetService("Chat"):FilterStringAsync("THIS IS THE STRING TO FILTERING NARB", game:GetService("Players").LocalPlayer, PlayerYouWantToSendThisTo)

To Conclude, if you have anymore questions, feel free to ask in the form of a comment, or even a totally different question.

3 comments

0

Thankyou for explaining the purpose of the function but could you explain how one might implement this in a function for a name Gui instead of just the chat?

0

For a name GUI, I find it easier to just use FilterStringForBroadcast(http://wiki.roblox.com/index.php?title=API:Class/Chat/FilterStringForBroadcast).

0

Thanks for your help already, but the wiki is so vague for anyone who has barely used the syntax, I've tried applying these two functions in lots of different ways and this is the closest I could get. It's still not functioning so I'll put one of my attempts up as a different question

This discussion is preserved as it was. New answers, comments, and votes are closed.