I am having issues with roblox filtering, where it’s not filtering the text. I’ve used the proper documentation Text Filtering | Documentation - Roblox Creator Hub but it’s still not working. I need help with this.
Thanks, I’ve tried re-scripting it multiple times and tried following tutorials and it’s still not working.
Here’s the code.
local EventSigns = game.Workspace.EventSigns
local TextService = game:GetService("TextService")
local Players = game:GetService("Players")
local function getFilteredText(unfilteredName, fromUserId)
local success, filteredText = pcall(function()
return TextService:FilterStringAsync(unfilteredName, fromUserId):GetNonChatStringForBroadcastAsync()
end)
if success then
if filteredText:find("%*") then
local tagCount = #filteredText:match("[^%*]+") or 0
return string.rep("#", tagCount)
end
return filteredText
else
warn("Error filtering text:", filteredText)
return nil
end
end
local function formatTime(timeInSeconds)
if timeInSeconds <= 0 then
return "Now"
elseif timeInSeconds < 60 then
return timeInSeconds .. "s"
elseif timeInSeconds < 3600 then
return math.floor(timeInSeconds / 60) .. "m"
else
return math.floor(timeInSeconds / 3600) .. "h"
end
end
local function updateTimeLabel(timeLabel, initialTime)
while initialTime > 0 do
timeLabel.Text = "<b>Time</b>: " .. formatTime(initialTime)
wait(1)
initialTime = initialTime - 1
end
timeLabel.Text = "<b>Time</b>: Now"
end
local function createEvent(host, filteredName, timeUntilStart)
for _, q in ipairs(EventSigns:GetChildren()) do
if q:IsA("Model") then
local Screen = q:FindFirstChild("Screen")
if Screen then
local ScrollFrame = Screen.SurfaceGui.ScrollingFrame
local Template = Screen.SurfaceGui.TemplateFolder.Template
if ScrollFrame and Template then
local Clone = Template:Clone()
Clone.Name = host.Name.."'s Event"
Clone.Visible = true
Clone.Parent = ScrollFrame
Clone.Frame.EventName.Text = filteredName
Clone.Frame.ImageLabel.Image = Players:GetUserThumbnailAsync(host.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
Clone.Frame.Host.Text = "<b>Host</b>: " .. host.Name
local timeLabel = Clone.Frame.Time
spawn(function()
updateTimeLabel(timeLabel, timeUntilStart)
end)
end
end
end
end
end
game.ReplicatedStorage.HostEvent.OnServerEvent:Connect(function(host, unfilteredName, timeUntilStart)
local filteredName = getFilteredText(unfilteredName, host.UserId)
if filteredName then
createEvent(host, filteredName, timeUntilStart)
end
end)