Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

[Solved] Text being filtered for no reason in textService:FilterStringAsync?

Asked by 4 years ago
Edited 3 years ago

EDIT 2: Turns out filtering only works in normal roblox, not in studio. thanks to https://devforum.roblox.com/t/how-to-use-the-filterstringasyncs-yield-functions/81735

My working script is this:




textService = game:GetService("TextService") game.ReplicatedStorage.NameChange.OnServerEvent:Connect(function(Player, Text) local FilteredText = "" local suc,err = pcall(function ()--filters name input FilteredText = textService:FilterStringAsync(Text, Player.UserId) end) print(Text) print(FilteredText) FilteredText = FilteredText:GetNonChatStringForBroadcastAsync() print(FilteredText) if not suc then--if filtering failed, name player the error Player.Character.Head.BillboardGui.TextLabel.Text = "#" print('filtered') end if suc then Player.Character.Head.BillboardGui.TextLabel.Text = FilteredText print("Success") end end)

EDIT: So I ran this in the console (warning it contains a swear word)

print(game.TextService:FilterStringAsync('shit', game.Players.UNBANhappyniceguy5.UserId):GetNonChatStringForBroadcastAsync())

and it just printed the swear word uncensored... am I doing something wrong?

ORIGINAL: So I have a custom role playing name script, but whatever I write gets filtered. Here's the script


textService = game:GetService("TextService") game.ReplicatedStorage.NameChange.OnServerEvent:Connect(function(Player, Text) local FilteredText = "" local suc,err = pcall(function ()--filters name input --name = chatService:FilterStringForBroadcast(Text,Player) print("attempt") FilteredText = textService:FilterStringAsync(Text, Player) print(FilteredText) end) print(suc) if not suc then--if filtering failed, name player the error Player.Character.Head.BillboardGui.TextLabel.Text = "#" print('filtered') end end)

It seems to not print the filtered text at line 10 so I guess the script is just skipping line 9 which is FilteredText = textService:FilterStringAsync(Text, Player)?

This is my first time doing filtering so I have no idea what's wrong.

0
Actually print the exception message at line 5. Probably something happened. Also, when you want to refer to a specific line, refer to the line relative to this code block, because line 13 and line 12 are not what you say it is. programmerHere 371 — 4y
0
oh sht, didn't notice the code block thing, one sec let me fix it. UNBANhappyniceguy5 52 — 4y
0
pls no swearing, incomplete or censored or not programmerHere 371 — 4y
0
Ok sorry. What do you mean "Actually print the exception message at line 5."? UNBANhappyniceguy5 52 — 4y
View all comments (5 more)
0
print(err) programmerHere 371 — 4y
0
Unable to cast Instance to int64 UNBANhappyniceguy5 52 — 4y
0
Turns out I had to make it Player.UserId, but it still doesn't work and just makes it pass the filter every time UNBANhappyniceguy5 52 — 4y
0
When I do print(FilteredText) it prints "Instance" instead of string UNBANhappyniceguy5 52 — 4y
0
You should mark your post as solved by putting [solved] at the start of your title. hiimgoodpack 2009 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Found an answer here

But what really ticked me off is your use of pcall.

You don't need to pass a function literal, you can just pass a reference to the FilterStringAsync method directly.

Maybe this will miraculously work and it's just something you did wrong and you didn't see it

local textService = game:GetService("TextService") -- pls use local variable

local successful, result = pcall(textService.FilterStringAsync, textService, Text, Player)

if successful then
    local result_success, filtered = pcall(result.GetNonChatStringForBroadcastAsync, result)
    Player.Character.Head.BillboardGui.TextLabel.Text = successful and filtered or "#"
end

If pcall returns true (it always returns a boolean first), then the return values after are the return values of the function passed. pcall also takes multiple arguments, not just a function. The arguments after the function are the arguments to the function passed. a:b(...) is syntactic sugar for a.b(a, ...) so textService is being passed as argument there so Lua knows what to call the method on

0
It doesn't seem to work, I get this error: ServerScriptService.Name Change:15: Expected ')' (to close '(' at line 14), got 'Player' UNBANhappyniceguy5 52 — 4y
0
look at my edit, is that normal? UNBANhappyniceguy5 52 — 4y
0
finally got it to work, thanks for trying. UNBANhappyniceguy5 52 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Turns out filtering only works in normal roblox, not in studio. thanks to https://devforum.roblox.com/t/how-to-use-the-filterstringasyncs-yield-functions/81735

0
What? You said it was being filtered for no reason. So the problem was it *wasn't*? Why didn't you specify that earlier? So I could have told you filtering didn't work in studio? programmerHere 371 — 4y

Answer this question