generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Text Filtering [Custom GUI]

Previous Thread :: Next Thread 
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 06:03 AM
How do I filter my custom chat GUI?

I've added these lines to my chat controller script:

local ChatService = game:GetService("Chat")


and


local filteredMessage
local success, filteredMessage = pcall(function() return ChatService:FilterStringAsync(player,message,ownercolor,textcolor) end)
if not success then
filteredMessage = "Failed to filter message"
end


it seems that wasn't enough to get it working...
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
01 Feb 2017 06:18 AM
FilterStringAsync(String, playerFrom, playerTo)

The arguments given, in your script, do not match up with those which are expected. You're equally throwing too many arguments at it - Why would you need to try cramming colours through a filter? It's absurd.

Equally, pcall is overkill - Which is also why you never received the error messages which it would have given to you.
Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 06:27 AM
OK, this is what I use now:

local filtered = game:GetService("Chat"):FilterStringAsync(message,player,player)

Now I've got another problem, it's with a local script in playergui.Chat.localscript...

Apparently, this:

local ownerText = Instance.new('TextLabel',script.Parent.Frame);
local message = Instance.new('TextLabel',script.Parent.Frame);
ownerText.Text = owner.Name..": ";
message.Text = text;

doesn't work well with FilterStringAsync.

This one:

message.Text = text;

is exactly line which it points as an error.
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
01 Feb 2017 06:31 AM
The error being...?

If you mean it just doesn't work, what's "text" defined as? As in, does a variable by that name exist? Surely you'd want to do 'message.text = filtered'
Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 06:34 AM
Here's another error after some more editing:

14:32:45.201 - Unable to cast value to Object
14:32:45.203 - Stack Begin
14:32:45.204 - Script 'Workspace.ChatController', Line 8
14:32:45.205 - Stack End


ChatController script:

local ChatService = game:GetService("Chat")

event = Instance.new('RemoteEvent',workspace)
event.Name = 'Chatted'


event.OnServerEvent:connect(function(message,player,player)
local filtered = game:GetService("Chat"):FilterStringAsync(message,player,player) < line 8
event:FireAllClients(filtered,player,player);
end)
Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 06:47 AM
OK did some more script cleaning up. Apparently the issue is with local script, I might even need to remake the whole local script from scratch...
Report Abuse
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
01 Feb 2017 06:48 AM
"Equally, pcall is overkill - Which is also why you never received the error messages which it would have given to you."

No, it's not. The filter service can fail some times.


Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 06:59 AM
The problem is that this new "FilterStringAsync" receives "Object" when it's suppose to get "String".

My script and chat gui works perfectly fine without "FilterStringAsync".

Somehow the problem is with local script:

game.StarterGui:SetCoreGuiEnabled('Chat',false)
game.StarterGui:SetCoreGuiEnabled('Health',false)
mouse = game.Players.LocalPlayer:GetMouse();
chatbox = Instance.new('TextBox',script.Parent);
chatbox.BackgroundColor3 = Color3.new(0,0,0);
chatbox.BackgroundTransparency = 0.5;
chatbox.BorderSizePixel = 0;
chatbox.Position = UDim2.new(0,0,1,-20);
chatbox.Size = UDim2.new(1,0,0,20);
chatbox.Font = 'SourceSans'
chatbox.FontSize = 'Size18';
chatbox.Text = "Click here or press / to chat.";
chatbox.TextColor3 = Color3.new(1,1,1);
chatbox.TextXAlignment = 'Left';
mouse.KeyDown:connect(function(key)
if key == "/" then
chatbox:CaptureFocus();
end
end)

function raiseAllText()
for i,v in pairs(script.Parent.Frame:children()) do
v.Position = v.Position - UDim2.new(0,0,0,20);
if v.Position.Y.Offset == 20 then v:remove() end
end
end

repeat wait() until workspace:FindFirstChild('Chatted');
workspace.Chatted.OnClientEvent:connect(function(player,text,ownercolor,messagecolor)
raiseAllText();
local ownerText = Instance.new('TextLabel',script.Parent.Frame);
local message = Instance.new('TextLabel',script.Parent.Frame);
ownerText.Text = script.Parent.Parent.Parent.Name..": ";
message.Text = text;
ownerText.TextColor3 = Color3.new(1,1,1);
message.TextColor3 = Color3.new(1,1,1);
ownerText.BackgroundTransparency = 1;
message.BackgroundTransparency = 1;
ownerText.TextStrokeTransparency = 0.2;
message.TextStrokeTransparency = 0.2;
ownerText.TextTransparency = 0.05;
message.TextTransparency = 0.05;
ownerText.BorderSizePixel = 0;
message.BorderSizePixel = 0;
ownerText.BackgroundColor3 = Color3.new(0,0,0);
message.BackgroundColor3 = Color3.new(0,0,0);
ownerText.Font = 'SourceSansBold';
message.Font = 'SourceSansBold';
ownerText.FontSize = 'Size18';
message.FontSize = 'Size18';
local tb = ownerText.TextBounds;
local tb2 = message.TextBounds;
ownerText.Position = UDim2.new(0,0,0,260);
ownerText.Size = UDim2.new(0,tb.X+5,0,20);
message.Size = UDim2.new(0,tb2.X+5,0,20);
message.Position = UDim2.new(0,tb.X+5,0,260);
end)
--When the player finishes their message and sends it
chatbox.FocusLost:connect(function(enterPressed)
if (not enterPressed) then return end
if (chatbox.Text == "" or chatbox.Text == " ") then chatbox.Text = 'Click here or press "/" to start chatting.' return end
workspace.Chatted:FireServer(chatbox.Text,Color3.new(1,1,1),Color3.new(1,1,1));
chatbox.Text = 'Click here or press / to chat.'
end)
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
01 Feb 2017 08:07 AM
@ForeverPower,
If ROBLOX expects you to use a trashy service to filter text, lest your game isn't shown to 13-, then it's a problem they need to address and fix as opposed to forcing people to litter a script with Pcalls.

At the end of the day, this shouldn't yield an error - If it does, then ROBLOX or the developer is implementing it wrong.

@OP,
As a note, you seem to do a lot of setting up in regards to the GUI elements - Why not just keep things simple and have a template which you clone, within the GUI given to players. It then means you forgo creating one from scratch.

Also, whilst I'm unsure what that error is from (given you've provided several different snippets), I'd assume that issue is with the fact that you're firing the clients with 'filtered, player' - When, on the client, it's "receiving" that as "player, text" - So, when you reference 'text', it's attempting to use the player object you've passed.
Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 08:19 AM
@DataStore
pls help me man

I've updated these parts for localscript:

repeat wait() until workspace:FindFirstChild('Chatted');
workspace.Chatted.OnClientEvent:connect(function(player,text,ownercolor,messagecolor)
raiseAllText();
local ownerText = Instance.new('TextLabel',script.Parent.Frame);
local message = Instance.new('TextLabel',script.Parent.Frame);
ownerText.Text = script.Parent.Parent.Parent.Name..": ";
message.Text = chatbox.Text; <<<<<
ownerText.TextColor3 = Color3.new(1,1,1);
message.TextColor3 = Color3.new(1,1,1);
ownerText.BackgroundTransparency = 1;
message.BackgroundTransparency = 1;
ownerText.TextStrokeTransparency = 0.2;
message.TextStrokeTransparency = 0.2;
ownerText.TextTransparency = 0.05;
message.TextTransparency = 0.05;
ownerText.BorderSizePixel = 0;
message.BorderSizePixel = 0;
ownerText.BackgroundColor3 = Color3.new(0,0,0);
message.BackgroundColor3 = Color3.new(0,0,0);
ownerText.Font = 'SourceSansBold';
message.Font = 'SourceSansBold';
ownerText.FontSize = 'Size18';
message.FontSize = 'Size18';
local tb = ownerText.TextBounds;
local tb2 = message.TextBounds;
ownerText.Position = UDim2.new(0,0,0,260);
ownerText.Size = UDim2.new(0,tb.X+5,0,20);
message.Size = UDim2.new(0,tb2.X+5,0,20);
message.Position = UDim2.new(0,tb.X+5,0,260);
end)
--When the player finishes their message and sends it
chatbox.FocusLost:connect(function(enterPressed)
if (not enterPressed) then return end
if (chatbox.Text == "" or chatbox.Text == " ") then chatbox.Text = 'Click here or press "/" to start chatting.' return end
workspace.Chatted:FireServer(chatbox.Text,Color3.new(1,1,1),Color3.new(1,1,1));
wait(1) <<<<<
chatbox.Text = 'Click here or press / to chat.'
end)



And now it WORKS, but doesn't filter ;(

After that I updated server script:

local ChatService = game:GetService("Chat")

event = Instance.new('RemoteEvent',workspace)
event.Name = 'Chatted'


event.OnServerEvent:connect(function(player,message)
local filtered = game:GetService("Chat"):FilterStringAsync(message,player,player)
event:FireClient(filtered,player,player);
end)

Now I am getting "Unable to cast value to Object" error. What should I do?
Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 08:26 AM
Update: replacing FilterStringAsync with filterStringForBroadcast makes it work, BUT doesn't filter inappropriate words. Why?
Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 08:36 AM
Even worse, with FilterStringForBroadcast it displays other person name as mine and that person text is Always "Click here or press / to chat."

Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
01 Feb 2017 09:00 AM
local filtered = {'noob','lame','lol'}

local msg = 'hi noobs you are all lame people lol'

local Filter = function(msg)
local s = msg
for i,v in next, filtered do
for m in msg:gmatch(v) do
s = s:gsub(m,string.rep('#',#m))
end
end
return s
end

print(Filter(msg))

>>hi ####s you are all #### people ###


Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
01 Feb 2017 09:09 AM
Time u have to use Robloxs own trash one
Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
01 Feb 2017 09:12 AM
local ChatService = game:GetService("Chat")

event = Instance.new('RemoteEvent',workspace)
event.Name = 'Chatted'


event.OnServerEvent:connect(function(player,message)
local filtered = game:GetService("Chat"):FilterStringAsync(message,player,player) < line 8
event:FireAllClients(filtered);
end)

Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 09:54 AM
@llaserx

When it's "FireAllClients" - event:FireAllClients(filtered);
Then it doesn't filter any of inappropriate words.

When changed to "FireClient" then it gives me error:"Unable to cast value to Object"
Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
01 Feb 2017 10:09 AM
event.OnServerEvent:connect(function(player,message)
local filtered = game:GetService("Chat"):FilterStringAsync(message,player,player)
for i,v in pairs(game.Players:GetPlayers() do
event:FireClient(v,filtered);
end
end)
Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
01 Feb 2017 10:10 AM
Wait no fireallclients works


Ur doing something wrong
Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 10:15 AM
Can you check localscript? I believe the issue lies within message.Text

Whenever someone else posts a message into chat, it appears as "Click here or press / to chat.", it's probably because message.Text = chatbox.Text; but in other cases I get error this error:

18:14:32.010 - Players.Player1.PlayerGui.Chat.LocalScript:34: bad argument #3 to 'Text' (string expected, got Object)
18:14:32.014 - Stack Begin
18:14:32.016 - Script 'Players.Player1.PlayerGui.Chat.LocalScript', Line 34
18:14:32.016 - Stack End



Here is local script:


game.StarterGui:SetCoreGuiEnabled('Chat',false)
game.StarterGui:SetCoreGuiEnabled('Health',false)
mouse = game.Players.LocalPlayer:GetMouse();
chatbox = Instance.new('TextBox',script.Parent);
chatbox.BackgroundColor3 = Color3.new(0,0,0);
chatbox.BackgroundTransparency = 0.5;
chatbox.BorderSizePixel = 0;
chatbox.Position = UDim2.new(0,0,1,-20);
chatbox.Size = UDim2.new(1,0,0,20);
chatbox.Font = 'SourceSans'
chatbox.FontSize = 'Size18';
chatbox.Text = "Click here or press / to chat.";
chatbox.TextColor3 = Color3.new(1,1,1);
chatbox.TextXAlignment = 'Left';
mouse.KeyDown:connect(function(key)
if key == "/" then
chatbox:CaptureFocus();
end
end)

function raiseAllText()
for i,v in pairs(script.Parent.Frame:children()) do
v.Position = v.Position - UDim2.new(0,0,0,20);
if v.Position.Y.Offset == 20 then v:remove() end
end
end

repeat wait() until workspace:FindFirstChild('Chatted');
workspace.Chatted.OnClientEvent:connect(function(message,player)
raiseAllText();
local ownerText = Instance.new('TextLabel',script.Parent.Frame);
local message = Instance.new('TextLabel',script.Parent.Frame);
ownerText.Text = script.Parent.Parent.Parent.Name..": ";
message.Text = chatbox.Text; <<<<<
ownerText.TextColor3 = Color3.new(1,1,1);
message.TextColor3 = Color3.new(1,1,1);
ownerText.BackgroundTransparency = 1;
message.BackgroundTransparency = 1;
ownerText.TextStrokeTransparency = 0.2;
message.TextStrokeTransparency = 0.2;
ownerText.TextTransparency = 0.05;
message.TextTransparency = 0.05;
ownerText.BorderSizePixel = 0;
message.BorderSizePixel = 0;
ownerText.BackgroundColor3 = Color3.new(0,0,0);
message.BackgroundColor3 = Color3.new(0,0,0);
ownerText.Font = 'SourceSansBold';
message.Font = 'SourceSansBold';
ownerText.FontSize = 'Size18';
message.FontSize = 'Size18';
local tb = ownerText.TextBounds;
local tb2 = message.TextBounds;
ownerText.Position = UDim2.new(0,0,0,260);
ownerText.Size = UDim2.new(0,tb.X+5,0,20);
message.Size = UDim2.new(0,tb2.X+5,0,20);
message.Position = UDim2.new(0,tb.X+5,0,260);
end)
--When the player finishes their message and sends it
chatbox.FocusLost:connect(function(enterPressed)
if (not enterPressed) then return end
if (chatbox.Text == "" or chatbox.Text == " ") then chatbox.Text = 'Click here or press "/" to start chatting.' return end
workspace.Chatted:FireServer(chatbox.Text,Color3.new(1,1,1),Color3.new(1,1,1));
wait(1)
chatbox.Text = 'Click here or press / to chat.'
end)
Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 10:22 AM
event.OnServerEvent:connect(function(player,message)
local filtered = game:GetService("Chat"):FilterStringAsync(message,player,player)
for i,v in pairs(game.Players:GetPlayers()) do
event:FireClient(v,filtered);
end
end)

This just also displays everyone else messages as "Click here or press / to chat." and doesn't filter inappropriate words I post.
Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
01 Feb 2017 10:30 AM
What is line 34
Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 10:42 AM
message.Text = chatbox.Text;
Report Abuse
llaserx is online. llaserx
Joined: 10 Dec 2011
Total Posts: 53069
01 Feb 2017 10:45 AM
Sir can u use ur brain and tell mr whats wrong
U can figure it out
Report Abuse
10MilesWide is not online. 10MilesWide
Joined: 06 Aug 2014
Total Posts: 2220
01 Feb 2017 10:49 AM
No he can't
He can't even read the wiki page for RemoteEvent
Report Abuse
Iliuminatis is not online. Iliuminatis
Joined: 30 Nov 2008
Total Posts: 1524
01 Feb 2017 10:52 AM
# ## use RemoteEvent, check the server script. This whole custom chat thing works perfectly fine without the new FilterStringAsync trash.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image