The sender must be connected to the server

I’m getting the error (stated in the title) on line 3 of this block of code.

EventFolder.Remotes.Typed.OnServerEvent:Connect(function(plr, Text)
	plrID = Players:GetUserIdFromNameAsync(plr)
	filteredTextResult = TextService:FilterStringAsync(Text, plrID) -- here
	Display.Text = filteredTextResult
end)

Don’t know what’s causing it, and I couldn’t find any sources online. Am I doing this correctly?
This is on a server script.

Filter string does not use the players UserId as a input. It uses the actual instance or object of the player. It also needs a player to argument. Look at the documentation here:

You could try something like this(if you put more data into the remote):

EventFolder.Remotes.Typed.OnServerEvent:Connect(function(plrFrom, plrTo, text)
	filteredTextResult = TextService:FilterStringAsync(text, plrFrom, plrTo) -- here
	Display.Text = filteredTextResult
end)

Well, there isn’t a single player receiving the text, but the whole server can see it.

Sooo…


I’m confused. I don’t think you got my message.

Try using this:

EventFolder.Remotes.Typed.OnServerEvent:Connect(function(plr, Text)

filteredTextResult = game:GetService("Chat"):FilterStringForBroadcast(Text, plr)

Display.Text = filteredTextResult

end)
1 Like

In addition, a pcall may be used in case of filter failures. However, this is all trivial and not relevant and the solution to it should be that the parameters are incorrectly assigned.

If the string is for everyone to see, the last question to answer is whether it persists after player leaves or if only the player is present.

The parameter to assign is the string as sent, then the UserId and then the third parameter. To get the player’s user ID properly, please refer to plr.UserId instead.

I recommend using Chat service instead of text service. Try using this script:

EventFolder.Remotes.Typed.OnServerEvent:Connect(function(plr, Text)
filteredTextResult = game:GetService("Chat"):FilterStringForBroadcast(Text, plr)
Display.Text = filteredTextResult
end)

The text stays very briefly, only for a few seconds.

pcall doesn’t help if the script isn’t working in the first place.

The reason why this isn’t working is because on line 2, you have Players:GetUserIdFromNameAsync(plr)
This function is supposed to take the player name, plr.Name
HOWEVER, you should definitely use plr.UserId directly as the UserId is literally a property.

Yeah I completely forgot about that lol

The error is gone, but now it doesn’t filter my text, even after inputting various… bad words.

Well that’s not really my fault. I am using what roblox has built in. Maybe it doesn’t filter in studio for testing?

I have already mentioned it was trivial, therefore shouldn’t be considered until the script base actually works before that. It’s just a consideration.

Yeah, it doesnt filter in studio. My bad. Thanks anyway.

Ah, looks like the important detail that was missed was that the chat you were using was the default one.

This class should have been considered in the first place before you use the TextService. You should only use the other service in case of inputs which allows player to set texts elsewhere than the default chat.

1 Like