Advertisement
SNL_HACKS

Name Hider

May 29th, 2019
5,149
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.97 KB | None | 0 0
  1. local Config =
  2. {
  3.    ProtectedName = "NameProtect", --What the protected name should be called.
  4.    OtherPlayers = true, --If other players should also have protected names.
  5.    OtherPlayersTemplate = "NameProtect", --Template for other players protected name (ex: "NamedProtect" will turn into "NameProtect1" for first player and so on)
  6.    RenameTextBoxes = false, --If TextBoxes should be renamed. (could cause issues with admin guis/etc)
  7.    UseMetatableHook = true, --Use metatable hook to increase chance of filtering. (is not supported on wrappers like bleu)
  8.    UseAggressiveFiltering = false --Use aggressive property renaming filter. (renames a lot more but at the cost of lag)
  9. }
  10.  
  11. local ProtectedNames = {}
  12. local Counter = 1
  13. if Config.OtherPlayers then
  14.    for I, V in pairs(game:GetService("Players"):GetPlayers()) do
  15.        ProtectedNames[V.Name] = Config.OtherPlayersTemplate .. tostring(Counter)
  16.        Counter = Counter + 1
  17.    end
  18.  
  19.    game:GetService("Players").PlayerAdded:connect(function(Player)
  20.        ProtectedNames[Player.Name] = Config.OtherPlayersTemplate .. tostring(Counter)
  21.        Counter = Counter + 1
  22.    end)
  23. end
  24.  
  25. local LPName = game:GetService("Players").LocalPlayer.Name
  26. local IsA = game.IsA
  27.  
  28. local function FilterString(S)
  29.    local RS = S
  30.    if Config.OtherPlayers then
  31.        for I, V in pairs(ProtectedNames) do
  32.            RS = string.gsub(RS, I, V)
  33.        end
  34.    end
  35.    RS = string.gsub(RS, LPName, Config.ProtectedName)
  36.    return RS
  37. end
  38.  
  39. for I, V in pairs(game:GetDescendants()) do
  40.    if Config.RenameTextBoxes then
  41.        if IsA(V, "TextLabel") or IsA(V, "TextButton") or IsA(V, "TextBox") then
  42.            V.Text = FilterString(V.Text)
  43.  
  44.            if Config.UseAggressiveFiltering then
  45.                V:GetPropertyChangedSignal("Text"):connect(function()
  46.                    V.Text = FilterString(V.Text)
  47.                end)
  48.            end
  49.        end
  50.    else
  51.        if IsA(V, "TextLabel") or IsA(V, "TextButton") then
  52.            V.Text = FilterString(V.Text)
  53.  
  54.            if Config.UseAggressiveFiltering then
  55.                V:GetPropertyChangedSignal("Text"):connect(function()
  56.                    V.Text = FilterString(V.Text)
  57.                end)
  58.            end
  59.        end
  60.    end
  61. end
  62.  
  63. if Config.UseAggressiveFiltering then
  64.    game.DescendantAdded:connect(function(V)
  65.        if Config.RenameTextBoxes then
  66.            if IsA(V, "TextLabel") or IsA(V, "TextButton") or IsA(V, "TextBox") then
  67.                V:GetPropertyChangedSignal("Text"):connect(function()
  68.                    V.Text = FilterString(V.Text)
  69.                end)
  70.            end
  71.        else
  72.            if IsA(V, "TextLabel") or IsA(V, "TextButton") then
  73.                V:GetPropertyChangedSignal("Text"):connect(function()
  74.                    V.Text = FilterString(V.Text)
  75.                end)
  76.            end
  77.        end
  78.    end)
  79. end
  80.  
  81. if Config.UseMetatableHook then
  82.    if not getrawmetatable then
  83.        error("GetRawMetaTable not found")
  84.    end
  85.  
  86.    local NewCC = function(F)
  87.        if newcclosure then return newcclosure(F) end
  88.        return F
  89.    end
  90.  
  91.    local SetRO = function(MT, V)
  92.        if setreadonly then return setreadonly(MT, V) end
  93.        if not V and make_writeable then return make_writeable(MT) end
  94.        if V and make_readonly then return make_readonly(MT) end
  95.        error("No setreadonly found")
  96.    end
  97.  
  98.    local MT = getrawmetatable(game)
  99.    local OldNewIndex = MT.__newindex
  100.    SetRO(MT, false)
  101.  
  102.    MT.__newindex = NewCC(function(T, K, V)
  103.        if Config.RenameTextBoxes then
  104.            if (IsA(T, "TextLabel") or IsA(T, "TextButton") or IsA(T, "TextBox")) and K == "Text" and type(V) == "string" then
  105.                return OldNewIndex(T, K, FilterString(V))
  106.            end
  107.        else
  108.            if (IsA(T, "TextLabel") or IsA(T, "TextButton")) and K == "Text" and type(V) == "string" then
  109.                return OldNewIndex(T, K, FilterString(V))
  110.            end
  111.        end
  112.  
  113.        return OldNewIndex(T, K, V)
  114.    end)
  115.  
  116.    SetRO(MT, true)
  117. end
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement