I wanna make a script that in a textbox detects a string then will replace it with something else then immediately submit it afterwords, in other words as in submit like if you are chatting then you press enter it submits the chat. I know I could use the chat RemoteEvent but I want to use this on all gui's not just chat.
local blacklist = { 'badword', 'badword2', } local RunService = game:GetService("RunService") local plr = game.Players.LocalPlayer local pgui = plr.PlayerGui RunService.RenderStepped:Connect(function() for i,v in pairs(pgui:GetDescendants()) do if v.ClassName == 'TextBox' or v.ClassName == 'TextLabel' or v.ClassName == 'TextButton' then for b,n in pairs(blacklist) do if string.find(v.Text,n) then v.Text = "#&*^(@" -- Not sure what to put here end end end end end)
So, to replace something in a string with something else you do
local NewString = string.gsub("String Here", "Bad String Here", function(String) return string.rep("Replacement Character Here", #String) end)
If you are filtering chat you should use
TextService:FilterStringAsync()