Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Improved Basic Protect Gui by darraghd493
- An improved variant of my Basic Protect Gui @ https://pastebin.com/QkvCpyKq
- ]]
- local CoreGui = game:GetService("CoreGui")
- local function randomString(len)
- local charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
- local result = {}
- for i = 1, len do
- result[i] = charset:sub(math.random(1, #charset), math.random(1, #charset))
- end
- return table.concat(result)
- end
- local protectgui = protect_gui or protectgui
- local gethui = get_hidden_gui or gethui
- local protectedInstances = {}
- local active = false
- local function init()
- if active then return end
- active = true
- local old
- old = hookmetamethod(game, "__namecall", function(...)
- local args = {...}
- if not checkcaller() and args[1] == game and getnamecallmethod() == "FindFirstChild" and args[3] == true then
- for _, v in ipairs(protectedInstances) do
- if v.Name == args[2] then
- return nil
- end
- end
- end
- return old(...)
- end)
- end
- local function protect(gui)
- gui.Name = randomString(32)
- if protectgui then
- protectgui(gui)
- gui.Parent = CoreGui
- return
- end
- if gethui then
- gui.Parent = gethui()
- return
- end
- init()
- table.insert(protectedInstances, gui)
- for _, v in pairs(gui:GetDescendants()) do
- table.insert(protectedInstances, v)
- end
- gui.Parent = CoreGui
- gui.DescendantAdded:Connect(function(v)
- table.insert(protectedInstances, v)
- end)
- end
- return protect
Advertisement
Add Comment
Please, Sign In to add comment