I have this code to filter the text and then put the text onto a name tag. However, the code runs all the way and doesn't filter anything. Any solution? Thanks! P.S. I also already tried to change the lines that change the text from "text" to "filteredText".
Script:
local TextService = game:GetService("TextService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local signLabel = script.Parent local setSignText = ReplicatedStorage.RoleplayChange 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) player.RoleplayNameValue.Value = filteredText player.Character.Head.RPName.TextLabel.Text = filteredText end end setSignText.OnServerEvent:Connect(onSetSignText)
Local script line:
game.ReplicatedStorage.RoleplayChange:FireServer(script.Parent.Parent.RPName.Text)
I figured out the answer, it only works on the main game.