local messagingservice = game:GetService("MessagingService")
local httpsservice = game:GetService("HttpService")
local textservice = game:GetService("TextService")
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local success,errormessage = pcall(function()
local data = {
["PlayerName"] = plr.Name;
["PlayerMessage"] = msg
}
messagingservice:PublishAsync("PlayerMessage",data)
end)
end)
end)
messagingservice:SubscribeAsync("PlayerMessage",function(message)
local success,errormessage = pcall(function()
local playerwhosent = message.Data["PlayerName"]
local messageplayersent = message.Data["PlayerMessage"]
if not game.Players:FindFirstChild(playerwhosent) then
local filteredmessage = nil
local success,errormessage = pcall(function()
filteredmessage = textservice:FilterStringAsync(messageplayersent,game.Players:FindFirstChild(playerwhosent))
end)
if filteredmessage ~= nil then
if not game.Players:FindFirstChild(playerwhosent) then
game.ReplicatedStorage.ChatMessageEvent:FireAllClients(playerwhosent,messageplayersent)
end
else
game.ReplicatedStorage.ChatMessageEvent:FireAllClients(playerwhosent,"#######")
end
end
end)
end)
Again⌠You arenât filtering correctly. My example above can show you how itâs to be done.
but it says there is no variable called filtering text
Could you send a screenshot or exact output? Also, why not just follow along with the example above? Itâs a revised version of exactly what you want. You can add and remove things as youâd like but youâre constantly filtering incorrectly.
sorry but there are 150 errors of kill bricks a second, its soo hard to send a screenshot, btw the chat works but the filtering donât work, if i say hi others see it as #####, how to fix this filtering
Your code is doing exactly what you told it to. Please look at my example to better understand pcalls and text filtering.
hello sir,
for FilterStringAsync(message,value)
the second value should be player, but what player should it be? as the player who sent message wonât be in server
yes i understood but when I copy pasted that script, all were tags, the filter is making all tags or maybe it broke
The second argument should be the senders userid. You can use game.Players:GetUserIdFromNameAsync() as used in my example.
Sir no error is getting printed but its still not working
Send both scripts you have pleaseâŚ
local script:
local textservice = game:GetService("TextService")
game.ReplicatedStorage.ChatMessageEvent.OnClientEvent:Connect(function(plrname,message)
game.StarterGui:SetCore("ChatMakeSystemMessage",{
Text = "["..plrname.."]: "..message;
TextSize = 18;
Color = Color3.fromRGB(255, 255, 255)
})
end)
server script:
local messagingservice = game:GetService("MessagingService")
local httpsservice = game:GetService("HttpService")
local textservice = game:GetService("TextService")
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local success,errormessage = pcall(function()
local data = {
["PlayerName"] = plr.Name;
["PlayerMessage"] = msg
}
messagingservice:PublishAsync("PlayerMessage",data)
end)
end)
end)
messagingservice:SubscribeAsync("PlayerMessage",function(message)
local success,errormessage = pcall(function()
local playerwhosent = message.Data["PlayerName"]
local messageplayersent = message.Data["PlayerMessage"]
if not game.Players:FindFirstChild(playerwhosent) then
local filteredmessage = nil
local success,errormessage = pcall(function()
filteredmessage = textservice:FilterStringAsync(messageplayersent,game.Players:GetUserIdFromNameAsync(playerwhosent))
end)
if filteredmessage ~= nil and success then
game.ReplicatedStorage.ChatMessageEvent:FireAllClients(playerwhosent,filteredmessage)
end
end
end)
end)
Again: You. Are. Not. Filtering. Correctly.
What you should do,
local success, err = pcall(function()
filtered = textservice:FilterStringAsync(messageplayersent, game.Players:GetUserIdFromNameAsync(playerwhosent))
filteredc = filtered:GetNonChatStringForBroadcastAsync()
end)
if success then
game.ReplicatedStorage.ChatMessageEvent:FireAllClients(playerwhosent,filteredc)
end
You are attempting to send the Instance returned from FilterStringAsync(). You are supposed to call one of the three functions on the TextFilterResult Instance returned.
In this case we use :GetNonChatStringForBroadcastAsync(). You fire the filteredc variable within ChatMessageEvent.
Sir it says there is no variable called:
local success, err = pcall(function()
filtered = textservice:FilterStringAsync(messageplayersent, game.Players:GetUserIdFromNameAsync(playerwhosent)) -- it says there is no variable called filtered and filteredc
filteredc = filtered:GetNonChatStringForBroadcastAsync()
end)
There is no variable called what? Please send the exact output.
its not output, i right clicked on script in roblox studio as its red under it,
in pcall function it says filteredc = âlineâ but it says there is no variable called filteredc to change its value to the text it filters
I donât know how youâre getting that? I have the same script open in studio and there are no red underlines? Can you send a screenshot.
Can you send a full screenshot? Thatâs hard to work with.