So I’m trying to create an anti cheat, that detects new UI’s inserted, I wrote some code which checks for everything in the game to see if its a UI and put the UI in the table, and then I checked for anything that is being added in the playerGUI, Is there any way to do this, without the need to go through all the descendants in the game to see if its a UI, as for a big game it lags so much!
Wdym? Im making it so that if a player gets in a car or something an a new UI pops up, it does not kick the player, thats why I made a table of all the UI’s in the entire game, so that if there was a shop or something and the script inserts the UI in the playerUI it does not kick him, my problem here is when Im making the table I would have to use Get descendants, to check for all UI’s no matter what there parent is
Anti cheat is a challenging problem. Instead of putting the UI’s in a table maybe you could just add the ChildAdded event to all the UI’s and if any of them are fired you know something was added.
Here is the code, again it works, its just that I’m trying to find a better way to use something else that does not include game:GetDescendants()
> wait() > local tablee = {} – Table cuz yes > local arrIndex = 0 > local plr = game.Players.LocalPlayer > for i,k in pairs(game:GetDescendants()) do > if k:IsA(“ScreenGui”) then > tablee[arrIndex] = k > arrIndex = arrIndex + 1 > end > end > plr.PlayerGui.ChildAdded:Connect(function(v) > if v:IsA(“ScreenGui”) then > print(“LOL”) > local found = false > for i,appa in pairs(tablee) do > if v.Name == appa.Name then > --plr:Kick(“Trashcan”) > found = true > break > end > end > if found == false then > plr:Kick(“New UI detected, RNS-DVED”) > end > end > end) > script.LocalScript.Changed:Connect(function() > if script.LocalScript.Enabled == false then > game.Players.LocalPlayer:Kick(“no”) > end > end)
If a shop in Workspace had code, to like make the UI appear when a part is clicked, then a new UI is being inserted, if that happend using your method would probably kick the player