I’m trying to create a name change GUI that filters the player’s inputted name and saves upon exiting the game. However, I’m confused by the scripting examples in this ROBLOX Developer article:
Is there a simpler way to filter strings for display on overhead GUI’s? I’ve attached a screenshot of the GUI’s simple layout for reference.
You would probably use TextFilterResult:GetNonChatStringForBroadcastAsync for this. You use it like so:
local TextService = game:GetService("TextService")
local success, result = pcall(function()
local filteredTextResult = TextService:FilterStringAsync(text, player.UserId)
result = filteredTextResult:GetNonChatStringForBroadcastAsync()
end)
if not success then
warn("Error filtering text:", text, ":", errorMessage)
-- Put code here to handle filter failure
else
-- Set the title of the player here
end
Please also note: you should never save filtered strings like this in datastores, you should save the unfiltered original string and filter that one every time you load it for setting their title. The filter can change over time, so you need to filter it from scratch every time they play.
Since the Overhead name is showen to all player’s you need to use TextService:FilterStringAsync(message, fromPlayerId)
All you have to do is send the text to the server with an remote function. then the server will use the player’s ID as FromPlayerId And the name as the Message, then it will return the name as filtered, any filtered text will tagged, you can do an string.find to check if its tagged or not determined on this you can return to the player its tagged, so they need to send an other Name
I’m still a little confused - Post #2 provided the server code, and I’m still unsure of what to do with the LocalScript in the TextButton and the overhead GUI.
Simply, I want it in a way where it will change the overhead GUI and save for next time via a DataStore. There is only one property to change in the overhead GUI, and that’s of course the RP name. The username and overhead GUI duplication is handled by another script.
You can use the code buildthomas provided to filter the string after it is sent from the client. When the NameFilter remote connects server side you can use the function getFilteredName in your code to filter it, it will either return the filtered string or an error.
I posted something here but forgot how stupid I can get when I’ve just woken up after a late night sleep.
Anyways, it seems you’re not doing anything with the filtered text except printing it. It should be printing the string and if it does, you just need to set it to the gui’s text. I know this sounds obvious but I’ve heard a few people asking why it doesn’t edit the text they just got from the gui, e.g.:
editText(someGui.Text)
-- or
textVariable = editText(textVariable)
ChatService filter methods (not recommended, superseded) and TextService::FilterStringAsync are the only methods of filtering strings, there is no “simpler” way because that’s the simplest it comes.
You seem to have the problem relying in your code, not the usage of the TextService, judging by prior conversation. Have you yourself attempted to pick at this problem? I never saw any scripts created in the initial Gui, nor any attempted code samples with this.
TextFilter::FilterStringAsync returns a TextFilterResult object, not a string. Literally speaking you can’t operate raw on what’s returned from this callback, but using a method of the TextFilterResult does return a string that can be used for operating purposes (running string operators or using the string).
@colbert2677 This is what I use for WYR to make sure player’s don’t post inappropriate Rather’s. But just a disclaimer Roblox isn’t always good at censoring stuff.