How am I suppose to filter text retrived from datastore?

I want to filter a nametag for my pets. That’s all.

It’s easily done when the player enters the name of the pet, just use

success, err = pcall(function()
	local result = TextService:FilterStringAsync(name, player.UserId)
	name = result:GetNonChatStringForBroadcastAsync()
end)

But I’m also encouraged by the wiki to save the unfiltered string and filter it every time the game loads.

https://create.roblox.com/docs/building-and-visuals/ui/text-filtering

But it doesn’t supply a single function that DOES JUST THAT!

I cant run FilterStringAsync without a userid. What am I suppose to do? Save the userid that created every single string too? Well guess what, you can’t! Because you get the error

The sender must be connected to the current server

So what am I suppose to do?

3 Likes

why dont you just store the filtered result, or both if needed, in the datastore?

1 Like

Because it explicitly says not to do that.

1 Like

if you store for example the unfiltered name of the pet that belongs to the player, there shouldnt be a problem with the UserId since the player is on the server?

1 Like

Unfortunatly not.
The island with his pets can be loaded without him being ingame.

Why not just save the unfiltered text, then when you load the text into the game you filter it each time?

That’s exactly what Im trying to do. But there’s no such function.

if you need to load the player’s data when they are not in the game, you can store the filtered and unfiltered pet name in the same string, such as “Name/FilteredName”, and then use string.split(string, "/") to get the names. you can update this value every time a player rejoins, there is no other way

I know how to save a string in a datastore, the problem is filtering that string without the author present in-game.

When you use result:GetNonChatStringForBroadcastAsync(), there is no player involved. It just filters the text.

1 Like

Have you tried doing

local result = TextService:FilterStringAsync(name)

without any userid?

As I said in my post, all you get is the error

The sender must be connected to the current server

Why do you need to get the filtered pet names of a player who isn’t in the server?

there is no way to filter the string without the player, they made it so that no one can use it maliciously to get someone in trouble
otherwise anyone could to get you banned / warned by doing this

TextService:FilterStringAsync("some bad words", YourUserId)
1 Like

image
Except Roblox explicitly encourage you to do just that.

yeah, and you can do it with a player on the server

this is the only solution if you need filtered text without the player in the game

edit: Please reply to this with an explanation as to why you need to load the data without the player on the server, maybe then i could help you

I think they only want you to re-filter it when the pet owner loads the game, not whenever any player loads the game. Unless you are displaying it someplace for other players to see when the owner isn’t playing, you shouldn’t have to worry about this. Just make sure the name is re-filtered and saved before it is displayed on the player’s pet during their visit.