Advertisement
XZTablets

Anti-Dex

Aug 27th, 2020 (edited)
1,752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.03 KB | None | 0 0
  1. local CoreGui = game:GetService("CoreGui");
  2.  
  3. local DexDependencies = {
  4.     Frame = 14,
  5.     LocalScript = 1,
  6.     ImageButton = 1,
  7. }
  8.  
  9. local CertaintyLevel = 0.8
  10. local DependencyLevel = 0.8
  11.  
  12. function TableContainsInstance(Table, Instance)
  13.     for _, Value in next, Table do
  14.         if (Value == Instance.Name) then
  15.             return true
  16.         end
  17.     end
  18.     return false
  19. end
  20.  
  21. function FindGuiInstancesWithIgnoreList(IgnoreList)
  22.     local IgnoreList = IgnoreList or {};
  23.     local Instances = {};
  24.     table.foreach(CoreGui:GetChildren(), function(_, Child)
  25.         local IsRobloxGui = TableContainsInstance(IgnoreList, Child)
  26.         if not IsRobloxGui then
  27.             table.insert(Instances, Child)
  28.         end
  29.     end)
  30.     return Instances
  31. end
  32.  
  33. function DeleteDex()
  34.     local PotentialDexInstances = FindGuiInstancesWithIgnoreList({
  35.         "RobloxGui",
  36.         "CoreScriptLocalization",
  37.         "RobloxPromptGui",
  38.         "PurchasePromptApp",
  39.         "RobloxNetworkPauseNotification",
  40.         "TopBar",
  41.         "DevConsoleMaster",
  42.         "RobloxLoadingGui"
  43.     })
  44.    
  45.     for _, Candidate in next, PotentialDexInstances do
  46.         if Candidate:IsA("ScreenGui") then
  47.             local DependencyTarget = 0
  48.             local DependenciesMet = 0
  49.             for Dependency, Target in next, DexDependencies do
  50.                 local Count = 0
  51.                 for _, Child in next, Candidate:GetChildren() do
  52.                     if Child:IsA(Dependency) then
  53.                         Count = Count + 1
  54.                     end
  55.                 end
  56.                 if ((Count / Target) >= DependencyLevel) then
  57.                     DependenciesMet = DependenciesMet + 1
  58.                 end
  59.                 DependencyTarget = DependencyTarget + 1
  60.             end
  61.             local Certainty = DependenciesMet / DependencyTarget
  62.             if (Certainty >= CertaintyLevel) then
  63.                 print(Candidate, "is Dex. Removing now.")
  64.                 Candidate:Destroy();
  65.             end
  66.         end
  67.     end
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement