My roblox place recently wend under 'moderation' for not having a filtering system in place for my RP Name gui and I was wondering if someone can help me go about this, I'm really confused about it. This is the current script I have for my RP Name gui. Thanks...
script.Parent.FocusLost:connect(function(enter) if enter then v = game.Players.LocalPlayer for a, mod in pairs(v.Character:children()) do if mod:findFirstChild("NameTag") then v.Character.Head.Transparency = 0.99 mod:Destroy() end end local char = v.Character local mod = Instance.new("Model", char) mod.Name = script.Parent.Text local cl = char.Head:Clone() cl.Parent = mod local hum = Instance.new("Humanoid", mod) hum.Name = "NameTag" hum.MaxHealth = 0 hum.Health = 0 local weld = Instance.new("Weld", cl) weld.Part0 = cl weld.Part1 = char.Head char.Head.Transparency = 1 end end)
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 -- we should probably validate this text before sending it ie not a blank string remoteEvent:FireServer(script.Parent.Text) -- send the text to the server 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
-- services local chatServ = game:GetService('Chat') -- variables local remoteEvent = [path to remote event] remoteEvent.OnServerEvent:Connect(function(plr, txt) -- the player is added by roblox as it knows who send the request -- we should validate what is being sent to us local char = plr.Character if char then -- if we have a character -- check for a previous tag for i, v in pairs(char:GetChildren()) do if v:FindFirstChild("NameTag") then v:Destroy() char.Head.Transparency = 0.99 break -- we have found the tag so we do not need to loop any more so break out of this loop end end local mod = Instance.new("Model") mod.Name = chatServ:FilterStringForBroadcast(txt, plr) -- filter this message -- clone and parent the players head 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.