Filtered string only returns "Instance"

I’m trying to make a nickname changer for my custom nametag script, however the filtered object always returns “Instance.”

image

This is the server script running the filtering.

game.ReplicatedStorage.Codename.OnServerEvent:Connect(function(p, m)
	local message = textservice:FilterStringAsync(m, p.UserId, Enum.TextFilterContext.PublicChat)
    local filteredMessage = message:GetNonChatStringForBroadcastAsync()
	p.Character.Head.NameGUI.NameText.Text = filteredMessage
end)

Any help would be appreciated. Thanks.

textservice:FilterStringAsync returns a TextFilterResult

Try using FilterStringAsync on the chat service and tell me how it goes.

Same thing, still returns Instance

can you print the filteredMessage?

I realized that that’s actually a deprecated function, my bad, this is a really weird bug.

After looking deeper into the function, have you tried it out in game?
“This method currently throws if fromUserId is not online on the current server. We plan to support users who are offline or on a different server in the future.”

Have you tried this in a live game? Studio might not recognize you as in the server.

I’ve tried it in a live game. It also prints Instance as well.

TextService:FilterStringAsync will return a TextFilterResult. If you look at the documentation, you will see that a TextFilterResult has 3 functions: GetChatForUserAsync(toUserId), GetNonChatStringForBroadcastAsync(), and GetNonChatStringForUserAsync(toUserId). Their documentation describes their proper use cases, however they all will return a string.

GetNonChatStringForBroadcastAsync() is the good one to use right now.

1 Like

Could you send me the data you’re sending to the server from the client?

Edit: I could imagine that it’s probably an issue with the client sending an instance in stead of a string

Yes, that’d be correct as all users will be able to see the string (Returns the text in a properly filtered manner for all users.)

The TextBox and TextButton are parented to a Frame.

script.Parent.MouseButton1Click:Connect(function()
	local player = game.Players.LocalPlayer
	local message = script.Parent.Parent.TextBox.Text
	game.ReplicatedStorage.Codename:FireServer(player, message)
	script.Parent.Parent.Parent.Enabled = false
end)

The output would return an error when using filter.

You’re sending the player in the fireserver, remember that .OnServerEvent has the player always as the first argument, just send :FireServer(message)

Edit: The reason it’s returning instance is because you’re trying to filter the player object.

Oh, just remove “player” when firing the remote event and it would be fixed. ^^ My bad, didn’t see the edit.

Yup, that fixed it! Thanks for your help everyone!

Damn, I keep forgetting about that.

2 Likes