Hello, I’m trying to make my Billboard GUI roleplay name system have the chat filter as it currently lets you type anything in, I created this script below:
In the first image, GetNonChatStringForBroadcastAsync is written as: GetNonChatStringForBroadcaseAsync, so replacing Broadcase with Broadcast should fix the problem
Hi thanks for the help, it hasn’t seemed to have done anything still, I can still type whatever as the name, is it potentially because the text is being assigned to the Billboard GUI before the filter does its job?
This should work (I tried to write it in the same code style you use):
local TextService = game:GetService("TextService")
local NametagEvent = game:GetService("ReplicatedStorage").NameTag
local Nametag = game:GetService("ServerStorage").RoleName
game:GetService("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)
NametagEvent.OnServerEvent:Connect(function(plr, Text)
print(plr, "wrote", Text)
local success, result = pcall(TextService.FilterStringAsync, TextService, Text, plr.UserId)
if success then
local success, filteredText = pcall(result.GetNonChatStringForBroadcastAsync, result)
if success then
plr.Character.Head.RoleName.RoleNameText.Text = filteredText
end
end
end)