Exgg_o
(egg)
July 23, 2020, 11:19pm
1
I’m trying to make a nickname changer for my custom nametag script, however the filtered object always returns “Instance.”
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.
Exgg_o
(egg)
July 23, 2020, 11:47pm
3
Same thing, still returns Instance
FerbZides
(FerbZides)
July 23, 2020, 11:48pm
4
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.
Exgg_o
(egg)
July 23, 2020, 11:53pm
6
I’ve tried it in a live game. It also prints Instance as well.
hpenney2
(hpenney2)
July 23, 2020, 11:53pm
7
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.
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
hpenney2
(hpenney2)
July 23, 2020, 11:55pm
10
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.)
Exgg_o
(egg)
July 23, 2020, 11:55pm
11
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.
Exgg_o
(egg)
July 23, 2020, 11:58pm
15
Yup, that fixed it! Thanks for your help everyone!
Damn, I keep forgetting about that.
2 Likes