Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- config
- local file_name = "GameDump_Decompiled.txt"
- local player_name = "USER"
- -- helper function to get the full path of an object
- local function get_path(obj)
- local path = {}
- while obj and obj ~= game do
- table.insert(path, 1, obj.Name)
- obj = obj.Parent
- end
- return "game." .. table.concat(path, ".")
- end
- -- helper function to get a script's source, using the decompiler as a backup
- local function get_source(script)
- local source = script.Source
- if source and #source > 0 then
- return source
- end
- -- if .Source is empty or protected, fall back to the decompiler
- if decompile then
- local success, result = pcall(decompile, script)
- if success then
- return result
- else
- return "--[[ DECOMPILER FAILED: " .. tostring(result) .. " ]]--"
- end
- end
- return "--[[ ERROR: Could not get source and 'decompile' is not available. ]]--"
- end
- -- // main // --
- -- rename the player
- local lp = game:GetService("Players").LocalPlayer
- local old_name = lp.Name
- lp.Name = player_name
- -- what we want to scan
- local services_to_scan = {
- ReplicatedStorage = game:GetService("ReplicatedStorage"),
- Workspace = game:GetService("Workspace"),
- StarterGui = game:GetService("StarterGui"),
- Players = game:GetService("Players"),
- Lighting = game:GetService("Lighting"),
- StarterPack = game:GetService("StarterPack"),
- }
- local hierarchy_dump = {}
- local scripts_dump = {}
- print("Dumping game... this might take a sec.")
- for _, service in pairs(services_to_scan) do
- if not service then continue end
- for _, descendant in ipairs(service:GetDescendants()) do
- local path = get_path(descendant)
- -- log the object's path and class
- table.insert(hierarchy_dump, string.format("%s | %s", path, descendant.ClassName))
- -- if it's a client-side script, grab its source
- if descendant:IsA("LocalScript") or descendant:IsA("ModuleScript") then
- local source = get_source(descendant)
- table.insert(scripts_dump, {
- Path = path,
- Class = descendant.ClassName,
- Source = source
- })
- end
- end
- end
- print("Scan finished. Building the text file...")
- -- build the final output file
- local final_dump = {
- "-- Game Dump --",
- string.format("-- User: %s (was %s)", player_name, old_name),
- string.format("-- Time: %s (UTC)", os.date("!%Y-%m-%d %H:%M:%S")),
- "\n------------------------------------------",
- "-- HIERARCHY",
- "------------------------------------------\n",
- table.concat(hierarchy_dump, "\n"),
- "\n\n------------------------------------------",
- "-- SCRIPTS (LocalScripts & ModuleScripts)",
- "------------------------------------------\n"
- }
- -- add the formatted script sources
- for _, data in ipairs(scripts_dump) do
- table.insert(final_dump, string.format("-- Path: %s\n-- Class: %s\n--[[ SOURCE ]]--\n\n%s\n\n--[[ END SOURCE ]]\n------------------------------------------\n", data.Path, data.Class, data.Source))
- end
- local full_output = table.concat(final_dump, "\n")
- -- attempt to write file, with clipboard as a fallback
- if writefile then
- writefile(file_name, full_output)
- print(string.format("Success! Saved everything to '%s'.", file_name))
- else
- if setclipboard then
- setclipboard(full_output)
- print("Couldn't save to a file, but that's okay.")
- print("Success! Copied everything to your clipboard. Paste it in a notes app!")
- else
- warn("FATAL: Your executor doesn't support 'writefile' or 'setclipboard'.")
- print("You'll have to copy the log from your console manually.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment