Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this GUI text filtering returning nil even in published game?

Asked by
lolzmac 207 Moderation Voter
5 years ago

I'm not too familiar with how the chat filtering stuff works, so I used a bit of code off the devforums, but still when I try to print the filtered result in an uploaded place, all I get is nil. This is filtered in a server script

Here's the code:

local TextService = game:GetService("TextService") 

local function onSetName(player, text)
    local TEXT_TO_FILTER = text
    local filterSuccess, filterResult = pcall(function() 
        local filteredTextResult = TextService:FilterStringAsync(TEXT_TO_FILTER, player.UserId) 
        filterResult = filteredTextResult:GetNonChatStringForBroadcastAsync() 
    end) 
    if not filterSuccess then 
        warn("Error filtering: ", TEXT_TO_FILTER) 
    else 
        print(filterResult)
    end
end


setname.OnServerInvoke = onSetName

Any ideas?

1 answer

Log in to vote
0
Answered by
lolzmac 207 Moderation Voter
5 years ago

Ah, seems like filterResult is nil when inside the pcall, I moved it outside and now it works fine.

Ad

Answer this question