Trying to censor text but roblox wants a.... object?

Hello, I’m trying to censor messages however it doesnt work

here is my script

		local gui = plr.PlayerGui.OtherUi.EmpireData.TextBox
		local sucess,failure = pcall(function()
		GloriousEmpire = TextService:FilterStringAsync(gui:GetNonChatStringForBroadcastAsync(), plr.UserId)
		end)

		if not sucess then
			print(failure)
			GloriousEmpire = ""
		end

it outputs

GetNonChatStringForBroadcastAsync is not a valid member of TextBox "Players.KrimsonWoIf.PlayerGui.OtherUi.EmpireData.TextBox"

I dont think that property Exists in a TextBox

okay how do I censor text? I looked at roblox’s documentation and it says I have to use

GetNonChatStringForBroadcastAsync()

on the object however I am not sure can you please help

thats from the TextFilterResult Class, TextService:FilterStringAsync will return this TextFilterResult and from there you can apply it.

I don’t understand.

just tell me how to do this and nothing else:

local message = "hello, I like to gamble at casinos"
local textService = game:GetService("TextService")
local CensoredMessage = TextService:FilterStringAsync(message)
-- code here to do something with message so it censors with ### and stuff
print(CensoredMessage)
local CensoredMessage = TextService:FilterStringAsync(message)
local thing = CensoredMessage:GetNonChatStringForBroadcastAsync()

Thats all?

If you want, you can declare the Variable as a TextFilterResult to help you with the functions:

local CensoredMessage: TextFilterResult = TextService:FilterStringAsync(message)

Hello I put

LOCAL SCRIPT

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	game.ReplicatedStorage.changeData:FireServer()
end)

SCRIPT

game.ReplicatedStorage.changeData.OnServerEvent:Connect(function(plr)

GloriousEmpire = gui.Text
local sucess,failure = pcall(function()
GloriousEmpire = TextService:FilterStringAsync(GloriousEmpire, plr.UserId)
GloriousEmpire = GloriousEmpire:GetNonChatStringForBroadcastAsync()
end)
gui.Text = GloriousEmpire
end)

however it lets me say some pretty terrible things and it does not censor any of it
(also now realising that gui.Text will not change on the server lmao)

i think you need to acces the text in the textbox:

plr.PlayerGui.OtherUi.EmpireData.TextBox.Text

instead of

plr.PlayerGui.OtherUi.EmpireData.TextBox

you cannot access text from a textbox on the server as its changed on the client

oh yeah i forgot, you could request the client the text, but they could hook the remote event

local gui = plr.PlayerGui.OtherUi.EmpireData.TextBox
		local sucess,failure = pcall(function()
		GloriousEmpire = TextService:FilterStringAsync(gui.Text, plr.UserId)
		end)

		if not sucess then
			print(failure)
			GloriousEmpire = ""
		end

???

it works lol
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
(not that but my most current version referencing the solution)

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