I have 2 scripts for my custom chat, There are 2 issues.The first is that the messages don't show up. The second is that I have a filtering code and I don't know whether it is to be put in one of the existing scripts or a new one.

Tutorial I used: https://www.youtube.com/watch?v=UWSJtv4lkg4

The LocalScript I added which is a child of a ScreenGUI which is a child of StarterGUI.

local textbox = script.Parent.Chat.Send.TextBox
local holder = script.Parent.Chat.Holder
local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local template = game.GetService("ReplicatedStorage"):WaitForChild("temp")

textbox.FocusLost:Connect(function(ep)
	if (ep) and textbox.Text ~= "" then
		event:FireServer(textbox.Text)
	else
			warn("Please enter text.")
	end
end)

event.OnClientEvent:Connect(function(message, plrThatSent)
	local clone = template:Clone()
	clone.plrName.Text = "[" .. plrThatSent .. "]:"
	clone.message.Text = message
	clone.Parent = script.Parent.Chat.Holder
end)

The Script which is a child of ServerScriptService

local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")


event.OnServerEvent:Connect(function(plr, message)
	if message ~= "" then
		event:FireAllClients(message, plr.Name)
	end
end)

The script to filter that I found online that I do not know where to enter.

local playerFrom = game.Players.LocalPlayer	-- Local player (player sending message)
local message = "Hello world!"	-- Message to be filtered
 
-- Filter the string and store the result in the 'FilteredString' variable
FilteredString = game:GetService("Chat"):FilterStringForBroadcast(message, playerFrom)
 
-- Print the filtered string
print(FilteredString)

How must I fix both issues?

2 comments

0

i think you have to use :FilterStringAsync() instead of :FilterStringForBroadcast()

0

alright, but where do i put the filter script