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

How do I get a message filtered in a GUI?

Asked by 3 years ago

Alright, so I've made a warning system, scripted it myself (copying = bad).

Anyways, I'd like to make it so the string is filtered, right now I get this result.

Here is a snippet of my code, I've tried to include FilterStringAsync() but got no where.

local WarnReason = Message:split(TargetUser)[2] -- !warn User **Reason**

WarningGuiClone.WarningNum.Value = WarningGuiClone.WarningNum.Value + 1 

WarningGuiClone.WarnLabel.Text = ("Warning "..WarningGuiClone.WarningNum.Value.." - "..WarnReason)

If you need more comment so!

Anyways thanks for the help, peace.

0
Can you list your attempts? User#30567 0 — 3y
0
Thank you, I've got it working Nicklaus_s 17 — 3y

2 answers

Log in to vote
1
Answered by 3 years ago
Edited by raid6n 3 years ago

Try using FilterStringForBroadcastAsync, which only uses two arguments.

You can learn more here! https://developer.roblox.com/en-us/api-reference/function/Chat/FilterStringForBroadcast

0
Fixed the link. raid6n 2196 — 3y
0
Thank you I've got it working. Nicklaus_s 17 — 3y
Ad
Log in to vote
0
Answered by
Benbebop 1049 Moderation Voter
3 years ago

The client cant use TextService

TextService is non-replicated, meaning it only works in ServerScripts. We'll need to send our string to the server and back.

How to get around this

We'll need to use RemoteFunctions.

Keep all your local code but instead trigger a RemoteFunction with the string you want to filter. Like so:

LocalScript

local RemoteFunction = -- The location of a RemoteFunction

RemoteFunction:InvokeServer(string)

Ref for InvokeServer

Now we filter it and return it.

ServerScript

local RemoteFunction = -- The location of the same RemoteFunction

RemoteFunction.OnServerInvoke = function(string)
    -- code to filter it
    return filteredString
end

Ref for OnServerInvoke

Back to the LocalScript so we can store the filtered string in a variable.

LocalScript

local RemoteFunction = -- The location of a RemoteFunction

local filteredString = RemoteFunction:InvokeServer(string)

Now you use filteredString for whatever you want to do with the filtered string.

That should be good, hope this helps!

Answer this question