This whole day ive been trying to make a roleplay name tag thing. I have gotten the basics down and now I need to add a filter. Ive been looking EVERY WHERE and cant find a simple way. Ive spent like 20 min just looking at the Filtering post on how it works. Right now I need some help. Please tell me how im supposed to do this since I have a tiny pea brain thanks. also im a text box for the name
Roblox has built in functions used both in the ChatService and TextService for filtering strings. I prefer to use the ChatService since you can decide upon using FilterStringForBroadcast which is for messages intended for the whole server to see or you can use FilterStringAsync if you are sending a string to certain players which may have a less strict chat filter applied to the message.
local Chat = game:GetService("Chat")
local function filterString(stringToFilter)
local filteredString = Chat:FilterStringForBroadcast(stringToFilter)
return filteredString
end
Here are the API links for more info:
So this is a script in server script service?
It says that theres a missing 2 argument on the local filtered string. Wich I have no idea how to fix since im new to this filtering
Can I see your current script and the output window? Most likley you missed over adding the Instance of the player sending the message, I forgot to mentain that in my code but it is outlined in the Developer Hub reference.
Did you look at the API reference for Chat:FilterStringForBroadcast? It should explain what needs to be added for the second argument.
Its a little bit confusing when you first attempt it, I have a chat script if you would like to take a look at it. Its well commented and if you have any questions feel free to let me know.
So I need to add the local player? Because thats what it seems to be showing
local ReplicatedStorage =game:GetService("ReplicatedStorage")
local ChatFilterService = game:GetService("TextService")
local Remote = ReplicatedStorage.SendMessage
Remote.OnServerEvent:Connect(function(Player, Message)
local Step1 = ChatFilterService:FilterStringAsync(Message, Player.UserId) -- We get
--- With the players user id, for filter
local Filter = Step1:GetNonChatStringForBroadcastAsync() -- we apply the filter
Remote:FireAllClients(Player, Filter) -- we send the filtered string
print(Filter)
end)
In essence this is how it works
Never mind when I add player it says Its Unable To Cast Value To Object on the same line
Bear mind, what I sent you works, That is exactly how you would filter a string. However you may notice the filter does not work in studio, this is because roblox does not want people to figure ways to bypass it.
I tested this but for some reason in your script the name is put to Instance
You cant copy it directly… This is to show how you do it not to serve as the script .
I am still getting confused though why cant roblox just auto filter
I fixed it now says instance now do you know how I can get the real text?
Can you show us your script? Since through this whole process we haven’t been able to keep track of what you have copied or deleted in your script.
What both me and @samjay22 posted are just examples that won’t just work for your uses. I did post links to the API reference which should help.
yes wich I did look at but there so confusing and were im just looking for help to guide me to the right direction
Could you please make the following discussion solved. By marking a message as solution.
But the issue hasn’t even been solved yet? Their is still issues present that are being resolved.