Am I using the right filtering method for this?

 local filteredName = name

    if name ~= player.DisplayName and name ~= player.Name then
        local ok, result = pcall(TextService.FilterStringAsync, TextService, filteredName, player.UserId)

        if ok then
            local o, filteredString = pcall(result.GetNonChatStringForUserAsync, result, player.UserId)

            if o then
                filteredName = filteredString
            else
                warn(tostring(result))
                return result
            end
        else
           warn(tostring(result))
           return result
        end
    end

    if filteredName ~= name then return false end

The game I’m working on right now has a local leader board for each player. When submitting a score to this leaderboard, the player can enter a custom name, which is filtered when submitted to the server.

Am I using the right method to filter these names? If not, which one should I be using instead?

Typically for a leaderboard with custom names you’d use broadcast since the name is intended to be seen by all visitors in your experience. That’s assuming the server is also responsible for displaying the names though (e.g. a SurfaceGui leaderboard). If it’s a per-player basis, you’re probably fine with GetNonChatStringForUserAsync (respects user’s privacy/policy information).