Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. local Config =
  2. {
  3. ProtectedName = "Azelo aka Riz Is Cool"
  4. OtherPlayers = true,
  5. OtherPlayersTemplate = "Azelo aka Riz Is Cool"
  6. RenameTextBoxes = false,
  7. UseFilterPadding = false,
  8. FilterPad = " ",
  9. UseMetatableHook = true,
  10. UseAggressiveFiltering = false
  11. }
  12.  
  13. local ProtectedNames = {}
  14. local Counter = 1
  15. if Config.OtherPlayers then
  16. for I, V in pairs(game:GetService("Players"):GetPlayers()) do
  17. local Filter = Config.OtherPlayersTemplate .. tostring(Counter)
  18. if Config.UseFilterPadding then
  19. if string.len(Filter) > string.len(V.Name) then
  20. Filter = string.sub(Filter, 1, string.len(V.Name))
  21. elseif string.len(Filter) < string.len(V.Name) then
  22. local Add = string.len(V.Name) - string.len(Filter)
  23. for I=1,Add do
  24. Filter = Filter .. Config.FilterPad
  25. end
  26. end
  27. end
  28. ProtectedNames[V.Name] = Filter
  29. Counter = Counter + 1
  30. end
  31.  
  32. game:GetService("Players").PlayerAdded:connect(function(Player)
  33. local Filter = Config.OtherPlayersTemplate .. tostring(Counter)
  34. if Config.UseFilterPadding then
  35. if string.len(Filter) > string.len(V.Name) then
  36. Filter = string.sub(Filter, 1, string.len(V.Name))
  37. elseif string.len(Filter) < string.len(V.Name) then
  38. local Add = string.len(V.Name) - string.len(Filter)
  39. for I=1,Add do
  40. Filter = Filter .. Config.FilterPad
  41. end
  42. end
  43. end
  44. ProtectedNames[Player.Name] = Filter
  45. Counter = Counter + 1
  46. end)
  47. end
  48.  
  49. local LPName = game:GetService("Players").LocalPlayer.Name
  50. local IsA = game.IsA
  51.  
  52. if Config.UseFilterPadding then
  53. if string.len(Config.ProtectedName) > string.len(LPName) then
  54. Config.ProtectedName = string.sub(Config.ProtectedName, 1, string.len(LPName))
  55. elseif string.len(Config.ProtectedName) < string.len(LPName) then
  56. local Add = string.len(LPName) - string.len(Config.ProtectedName)
  57. for I=1,Add do
  58. Config.ProtectedName = Config.ProtectedName .. Config.FilterPad
  59. end
  60. end
  61. end
  62.  
  63. local function FilterString(S)
  64. local RS = S
  65. if Config.OtherPlayers then
  66. for I, V in pairs(ProtectedNames) do
  67. RS = string.gsub(RS, I, V)
  68. end
  69. end
  70. RS = string.gsub(RS, LPName, Config.ProtectedName)
  71. return RS
  72. end
  73.  
  74. for I, V in pairs(game:GetDescendants()) do
  75. if Config.RenameTextBoxes then
  76. if IsA(V, "TextLabel") or IsA(V, "TextButton") or IsA(V, "TextBox") then
  77. V.Text = FilterString(V.Text)
  78.  
  79. if Config.UseAggressiveFiltering then
  80. V:GetPropertyChangedSignal("Text"):connect(function()
  81. V.Text = FilterString(V.Text)
  82. end)
  83. end
  84. end
  85. else
  86. if IsA(V, "TextLabel") or IsA(V, "TextButton") then
  87. V.Text = FilterString(V.Text)
  88.  
  89. if Config.UseAggressiveFiltering then
  90. V:GetPropertyChangedSignal("Text"):connect(function()
  91. V.Text = FilterString(V.Text)
  92. end)
  93. end
  94. end
  95. end
  96. end
  97.  
  98. if Config.UseAggressiveFiltering then
  99. game.DescendantAdded:connect(function(V)
  100. if Config.RenameTextBoxes then
  101. if IsA(V, "TextLabel") or IsA(V, "TextButton") or IsA(V, "TextBox") then
  102. V:GetPropertyChangedSignal("Text"):connect(function()
  103. V.Text = FilterString(V.Text)
  104. end)
  105. end
  106. else
  107. if IsA(V, "TextLabel") or IsA(V, "TextButton") then
  108. V:GetPropertyChangedSignal("Text"):connect(function()
  109. V.Text = FilterString(V.Text)
  110. end)
  111. end
  112. end
  113. end)
  114. end
  115.  
  116. if Config.UseMetatableHook then
  117. if not getrawmetatable then
  118. error("GetRawMetaTable not found")
  119. end
  120.  
  121. local NewCC = function(F)
  122. if newcclosure then return newcclosure(F) end
  123. return F
  124. end
  125.  
  126. local SetRO = function(MT, V)
  127. if setreadonly then return setreadonly(MT, V) end
  128. if not V and make_writeable then return make_writeable(MT) end
  129. if V and make_readonly then return make_readonly(MT) end
  130. error("No setreadonly found")
  131. end
  132.  
  133. local MT = getrawmetatable(game)
  134. local OldNewIndex = MT.__newindex
  135. SetRO(MT, false)
  136.  
  137. MT.__newindex = NewCC(function(T, K, V)
  138. if Config.RenameTextBoxes then
  139. if (IsA(T, "TextLabel") or IsA(T, "TextButton") or IsA(T, "TextBox")) and K == "Text" and type(V) == "string" then
  140. return OldNewIndex(T, K, FilterString(V))
  141. end
  142. else
  143. if (IsA(T, "TextLabel") or IsA(T, "TextButton")) and K == "Text" and type(V) == "string" then
  144. return OldNewIndex(T, K, FilterString(V))
  145. end
  146. end
  147.  
  148. return OldNewIndex(T, K, V)
  149. end)
  150.  
  151. SetRO(MT, true)
  152. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement