So recently I have added a feature to my Roblox game that allows the plaver to type in a name for themselves, and have it appear overhead.
For some context: I do not adequatelv know Lua well enough, I can read it over and know roughly what something does, but I cannot write it. I added this feature pre-made from someone on youtube, but annovinalv the didn't add text filtration - so now players could literally swear in their nametags if they wanted to, meaning my game could be subject to moderator action.
I do have someone that's tried to helo me. but we're still running into some problems and I will likely need to un- privatise this game very soon as it is a virtual event venue. Thev have provided me with code which I have added (To filter player's inputted text if it is bad through roblox's own system), but it keeps failing to work and is now outputting no text at all regardless of whether it is permissible or not.
Here is the code I now have. If anyone could help me and tell me what I need to change to make this work i'd be so grateful!
local NametagEvent = game:GetService("ReplicatedStorage").NameTag
local Nametag = script.TextName
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(Char)
local TagClone = Nametag:Clone()
if Char:FindFirstChild("Head") then
TagClone.Parent = Char.Head
end
end)
end)
local NameTagEvent = game:GetService("ReplicatedStorage").NameTag
local TextService = game:GetService("TextService")
local function filterMessage(msg,fromUser)
local result
local success, err = pcall (function()
result = TextService:FilterStringAsync(msg, fromUser)
end)
if success then
result:GetNonChatStringForBroadcastAsync()
end
end
NameTagEvent.OnServerEvent:Connect(function(plr,text)
print(plr,"wrote",text)
plr.Character.Head.TextName.TextLabel.Text = filterMessage(text,plr)
end)
