So I followed this example [example 2] from roblox developer hub and it doesnt seem to work for me. Am I doing something wrong?
I’m trying to filter a string that is displayed on a surface gui in workspace.
local rs = game:GetService("ReplicatedStorage")
local TextService = game:GetService("TextService")
local function getTextObject(message, fromPlayerId)
local textObject
local success, errorMessage = pcall(function()
textObject = TextService:FilterStringAsync(message, fromPlayerId)
end)
if success then
return textObject
elseif errorMessage then
print("Error generating TextFilterResult:", errorMessage)
end
return false
end
local function getFilteredMessage(textObject)
local filteredMessage
local success, errorMessage = pcall(function()
filteredMessage = textObject:GetNonChatStringForBroadcastAsync()
end)
if success then
return filteredMessage
elseif errorMessage then
print("Error filtering message:", errorMessage)
end
return false
end
-- Fired when client sends a request to write on the sign
local function onSetSignText(player, text)
if text ~= "" then
-- Filter the incoming message and send the filtered message
local messageObject = getTextObject(text, player.UserId)
local filteredText = ""
filteredText = getFilteredMessage(messageObject)
ui.TextLabel.Text = filteredText
end
end
rs.EditBooth.OnServerEvent:Connect(function(plr, text2)
onSetSignText(plr, text2)
end)
there are no errors in output.