You need to send the text to the server so that it can be filtered as we do not trust the client, it would be best to store the players RP name on the server so it can be loaded each time they spawn.
To do this we use a remote event, some more info can be found here. Note that to be able to use remote events and functions you do not need to enable filtering though it is highly recommended that you use FE.
A remote event must be in a place that both the server and client can access it such as ReplicatedStorage(most commonly used), ReplicatedFirst or the Workspace.
As we only need to send data it would be best to use a remote event to send the users test to the sever then check the RP name.
Example:-
Client side (local script)
local remoteEvent = [path to remote event]
script.Parent.FocusLost:Connect(function(enter)
if enter then
remoteEvent:FireServer(script.Parent.Text)
end
end)
To filter the users RP name we need to use FilterStringForBroadcast as all players will see it not just playera an playerb.
Server script
local chatServ = game:GetService('Chat')
local remoteEvent = [path to remote event]
remoteEvent.OnServerEvent:Connect(function(plr, txt)
local char = plr.Character
if char then
for i, v in pairs(char:GetChildren()) do
if v:FindFirstChild("NameTag") then
v:Destroy()
char.Head.Transparency = 0.99
break
end
end
local mod = Instance.new("Model")
mod.Name = chatServ:FilterStringForBroadcast(txt, plr)
local charHead = char.Head:Clone()
charHead .Parent = mod
local hum = Instance.new("Humanoid")
hum.Name = "NameTag"
hum.MaxHealth = 0
hum.Health = 0
local weld = Instance.new("Weld")
weld.Part0 = cl
weld.Part1 = char.Head
weld.Parent = charHead
char.Head.Transparency = 1
charHead.Parent = char
end
end)
The code above is just an example of how this can be done, please comment if you need any more information about how remote events work so I can include more links.
I hope this helps.