How would i add filtering to a text label?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    a literal filter for my textlabel
  2. What is the issue? Include screenshots / videos if possible!
    i got a textlabel and a serverscript with a local script and what they do is when you say “/tweet hi” its going to show a gui on everyones screen saying “hi” and showing who said that, the thing is i can say bad words and it won’t be filtered
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i tried finding a tutorial on youtube and searched alot of devforum posts, but nothing worked

heres the local script inside starterplayerscripts:

local remoteEvent = game.ReplicatedStorage.RemoteEvent
local player = game.Players.LocalPlayer
local UI = player.PlayerGui.NotificationGui
local Players = game:GetService("Players")
remoteEvent.OnClientEvent:Connect(function(Message : string,Name : string)
	UI.Enabled = true
	UI.TextLabel.Text = Message
	UI.PlayerName.Text = Name.." Tweeted:"
	task.wait(5)
	UI.Enabled = false
end)

and here’s the serverscript in serverscriptservice:

local remoteEvent = game.ReplicatedStorage.RemoteEvent
	local players = game.Players

players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg:sub(1,7) ~= "/tweet " then return end

		local Message = msg:sub(8,string.len(msg))
		remoteEvent:FireAllClients(Message,plr.Name)
	end)
end)
2 Likes

You can use TextService:FilterStringAsync. Note that a TextFilterResult can’t be passed into a remote event, so you’ll need to send the filtered string instead.

1 Like

yo i remember you from the “how to make a zone” or sum like that, how ya doing. also the problem is that i have no idea how to do that.

1 Like

Please do not make duplicate topics about the same damn thing. Learn about updating topics.
Also for this:

Textlabel.Text = game:GetService("Chat"):FilterStringForBroadcast(sentstring,playerfrom)

Or in your case:

local remoteEvent = game.ReplicatedStorage.RemoteEvent
local players = game.Players

players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg:sub(1,7) ~= "/tweet " then return end

		local Message = msg:sub(8,string.len(msg))
		Message = game:GetService("Chat"):FilterStringForBroadcast(Message, plr)
		remoteEvent:FireAllClients(Message,plr.Name)
	end)
end)

Omg how did I write code on mobile!?!

it actually works, im just stupid as heck.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.