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.
1 | local WarnReason = Message:split(TargetUser) [ 2 ] -- !warn User **Reason** |
2 |
3 | WarningGuiClone.WarningNum.Value = WarningGuiClone.WarningNum.Value + 1 |
4 |
5 | WarningGuiClone.WarnLabel.Text = ( "Warning " ..WarningGuiClone.WarningNum.Value.. " - " ..WarnReason) |
If you need more comment so!
Anyways thanks for the help, peace.
Try using FilterStringForBroadcastAsync, which only uses two arguments.
You can learn more here! https://developer.roblox.com/en-us/api-reference/function/Chat/FilterStringForBroadcast
TextService is non-replicated, meaning it only works in ServerScripts. We'll need to send our string to the server and back.
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
1 | local RemoteFunction = -- The location of a RemoteFunction |
2 |
3 | RemoteFunction:InvokeServer(string) |
Ref for InvokeServer
Now we filter it and return it.
ServerScript
1 | local RemoteFunction = -- The location of the same RemoteFunction |
2 |
3 | RemoteFunction.OnServerInvoke = function (string) |
4 | -- code to filter it |
5 | return filteredString |
6 | end |
Ref for OnServerInvoke
Back to the LocalScript so we can store the filtered string in a variable.
LocalScript
1 | local RemoteFunction = -- The location of a RemoteFunction |
2 |
3 | local filteredString = RemoteFunction:InvokeServer(string) |
Now you use filteredString
for whatever you want to do with the filtered string.