I’ve gotten stuck at a point where I’m not sure how to filter the Text that was left input from a GUI; then sent to a Server, after that sent to a module.
I don’t really have much of an idea on how to use the Chat Filtering on strings - that is not by default chat.
Here is the code I have worked my way up to (The problem is at line 2):
function CreateFaction(FactionOwner, FactionName, FactionIcon, FactionRanks)
if game:GetService("Chat"):FilterStringForBroadcast(FactionName, FactionOwner) ~= FactionName then -- This is the problem.
else
warn("Faction name was Filtered.")
end
end
A possible solution to this would be to use a RemoteFunction to fetch the filtered string from the Server and then use it for the comparison, unless you strictly want a way to filter it on the Client/without using the Chat service at all. Keep in mind that it takes a lot more to accidentally “DDoS” a game server, so this most likely wouldn’t harm.
Client
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local filter = ReplicatedStorage:WaitForChild("Filter")
--other code
function createFaction(factionOwner, factionName, factionIcon, factionRanks)
if filter:InvokeServer(factionName) ~= factionName then -- a quick fix; your code mistakenly checks if the filtered string differs from the original one, then outputs a warning if it **doesn't**. That's supposed to be the other way around.
warn("Faction name was filtered.")
end
end
Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Chat = game:GetService("Chat")
local filter = ReplicatedStorage:WaitForChild("Filter")
filter.OnServerInvoke = function(Player, s)
return Chat:FilterStringForBroadcast(s, Player)
end
Please point out any mistakes I made, it’s pretty late over here. I suspect my problem solving capabilities may be failing.
That is also a solution, but you shouldn’t entrust the client to the point where it handles security checks without any help from the server, as this could easily be bypassed and possibly have your game looked into by moderation. Players have full control over their Client, so as long as someone knows what they’re doing, they could edit the LocalScript and have an unfiltered string be sent out to the server for the eyes of other players.Source: happened to me before.
If this is meant to be more of a warning than a security check and it does not really affect the string in the end, you should use Chat:FilterStringForBroadcast() as soon as the string is sent to the server.