### Install Project Requirements Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/README.md After creating a virtual environment, install the necessary project dependencies using pip and the requirements.txt file. ```sh python3 -m pip install -r requirements.txt ``` -------------------------------- ### Reading the bytecode of a running script Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Scripts/getscriptbytecode.md This example demonstrates how to get the bytecode of a script that is currently running in the game. It also shows how to handle cases where a script might not have any bytecode, such as a newly created instance. ```luau function getscriptbytecode(script: BaseScript | ModuleScript): string | nil end ``` ```luau local animate = game.Players.LocalPlayer.Character:FindFirstChild("Animate") print(getscriptbytecode(animate)) -- Returns bytecode as a string print(getscriptbytecode(Instance.new("LocalScript"))) -- Output: nil ``` -------------------------------- ### Get Script Hash Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Scripts/getscripthash.md This example demonstrates how to get the SHA-384 hash of a live script instance. It also shows that `nil` is returned for a newly created script without any bytecode. ```luau function getscripthash(script: BaseScript | ModuleScript): string | nil ``` ```luau local Animate = game.Players.LocalPlayer.Character:FindFirstChild("Animate") print(getscripthash(Animate)) -- Output: 384-bit hash string print(getscripthash(Instance.new("LocalScript"))) -- Output: nil ``` -------------------------------- ### Example 1: Inspecting and invoking a Luau connection Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Signals/getconnections.md This example demonstrates how to use `getconnections` to retrieve a `Connection` object for a Luau-defined signal and then invoke its associated function. ```APIDOC ## Example 1: Inspecting and invoking a Luau connection ### Description This example shows how to get a connection from a signal and then invoke the function associated with that connection. ### Code ```luau local folder = Instance.new("Folder") folder.ChildAdded:Connect(function() print("Triggered") end) local connection = getconnections(folder.ChildAdded)[1] -- First connection in the list connection.Function() -- Output: Triggered connection:Fire() -- Same as above, Output: Triggered print(typeof(connection.Thread)) -- Output: thread ``` ``` -------------------------------- ### Example Usage of `hookmetamethod` Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Closures/hookmetamethod.md An example demonstrating how to use `hookmetamethod` to hook the `__index` metamethod of a game object and then restore it. ```APIDOC ```luau title="Easily hooking metamethods with hookmetamethod" linenums="1" local original; original = hookmetamethod(game, "__index", function(...) local key = select(2, ...) print(key) return original(...) end) local _ = game.PlaceId -- Output: "PlaceId" hookmetamethod(game, "__index", original) -- Restores game's __index ``` ``` -------------------------------- ### Example 2: Accessing a foreign/C connection Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Signals/getconnections.md This example illustrates accessing a `Connection` object for a signal that might be implemented in C, showing that the `Function` and `Thread` properties may be nil in such cases. ```APIDOC ## Example 2: Accessing a foreign/C connection ### Description This example demonstrates accessing a connection for a signal that might be implemented in C. For such connections, the `Function` and `Thread` properties are typically nil. ### Code ```luau local cconnection = getconnections(game.Players.LocalPlayer.Idled)[1] print(cconnection.Function) -- Output: nil print(cconnection.Thread) -- Output: nil ``` ``` -------------------------------- ### Example: Responding to incoming messages Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/WebSocket/README.md Demonstrates how to use the `OnMessage` event and `Send` method to echo messages. ```APIDOC ## Example: Using the `OnMessage` event, and `Send` method ### Description This example shows how to connect to a WebSocket server, print incoming messages, and send a message. ### Code ```luau local ws = WebSocket.connect("wss://ws.postman-echo.com/raw") ws.OnMessage:Connect(function(message) print(message) end) ws:Send("Hello") -- Output: Hello ``` ``` -------------------------------- ### Reading a file Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Filesystem/readfile.md Use `readfile` to get the content of a file. Ensure the file exists before calling, as it will error otherwise. This example first writes content to a file and then reads it back. ```luau writefile("file0.txt", "Hello") print(readfile("file0.txt")) -- Output: Hello ``` -------------------------------- ### Example: Closing the connection Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/WebSocket/README.md Demonstrates how to use the `OnClose` event and `Close` method to handle connection closure. ```APIDOC ## Example: Using the `OnClose` event, and `Close` method ### Description This example shows how to connect to a WebSocket server, listen for the close event, and then close the connection. ### Code ```luau local ws = WebSocket.connect("wss://ws.postman-echo.com/raw") ws.OnClose:Connect(function() print("Closed") end) ws:Close() -- Output: Closed ``` ``` -------------------------------- ### Luau Example Code Block Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/About/contributing.md Include at least one example for every function. Use the 'Example' or 'Examples' heading appropriately. Each example must use Luau syntax highlighting, have line numbers enabled, and include a descriptive title. ```luau -- an example is here print("Hello world!") print("This is some example code") ``` -------------------------------- ### Basic File Writing Example Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Filesystem/writefile.md Use `writefile` to write a string to a file and then `readfile` to verify its contents. Ensure the file path is correct and the data is a string. ```luau writefile("file.txt", "Hello world") print(readfile("file.txt")) -- Output: Hello world ``` -------------------------------- ### Example 2: Full GC Scan Including Tables Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Environment/getgc.md This example shows how to use `getgc(true)` to include tables in the garbage collector scan. It verifies the presence of both a dummy function and a dummy table. ```APIDOC ```luau title="Full GC scan including tables" linenums="1" local dummy_table = {} local function dummy_function() end task.wait(0.05) -- Step a bit for _, value in pairs(getgc(true)) do if value == dummy_function then print(`Found function: {dummy_function}`) -- Should print elseif value == dummy_table then print(`Found table: {dummy_table}`) -- Should also print end end ``` ``` -------------------------------- ### Example 1: Function-only GC Scan Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Environment/getgc.md This example demonstrates how to use `getgc()` without any arguments to retrieve only functions and userdatas. It checks if a specific dummy function is present in the garbage collector's list. ```APIDOC ```luau title="Function-only GC scan" linenums="1" local dummy_table = {} local function dummy_function() end task.wait(0.05) -- Step a bit for _, value in pairs(getgc()) do if value == dummy_function then print(`Found function: {dummy_function}`) elseif value == dummy_table then print(`Found table?: {dummy_table}`) -- This shouldn't print end end ``` ``` -------------------------------- ### Create Python Virtual Environment Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/README.md Use this command to create a Python virtual environment for working on the documentation platform. Ensure Python 3 is installed. ```sh python3 -m venv venv ``` -------------------------------- ### Using getcustomasset to Load and Play a Sound Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Filesystem/getcustomasset.md This example demonstrates how to use `getcustomasset` to load a sound from a base64 encoded string, save it as an MP3 file, convert it to an asset ID, and then play it in-game. Ensure the `base64decode` function is available in your environment. ```luau local encoded = game:HttpGet("https://gitlab.com/sens3/nebunu/-/raw/main/encodedBytecode.txt") writefile("ExampleSound.mp3", base64decode(encoded)) local asset_id = getcustomasset("ExampleSound.mp3") local sound = Instance.new("Sound") sound.Parent = workspace sound.SoundId = asset_id sound.Volume = 0.35 sound:Play() ``` -------------------------------- ### Listing files in the root directory Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Filesystem/listfiles.md This example demonstrates how to use `listfiles` to find files in the root directory. It first creates two files, waits for them to be available, and then iterates through the listed files, printing a message when specific files are found. ```luau writefile("file1.txt", "") writefile("file2.lua", "") task.wait() for _, file in listfiles("") do if file == "file1.txt" then print(`Found: {file}`) -- Output: Found: file1.txt end if file == "file2.lua" then print(`Found: {file}`) -- Output: Found: file2.lua end end ``` -------------------------------- ### Triggering a ProximityPrompt Manually Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Instances/fireproximityprompt.md This example demonstrates how to create a `Part` and a `ProximityPrompt` within it, connect a `Triggered` event, and then use `fireproximityprompt` to manually trigger the prompt. ```luau local part = Instance.new("Part", workspace) local prompt = Instance.new("ProximityPrompt", part) prompt.ActionText = "Click Me" prompt.Triggered:Connect(function(player) print(player.Name .. " triggered the prompt") end) fireproximityprompt(prompt) -- Output: [YourName] triggered the prompt ``` -------------------------------- ### Enumerate All Game Instances Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Retrieve all instances in the game registry using `getinstances()`. Use `getnilinstances()` to specifically get currently unparented instances. ```luau function getinstances(): { Instance } function getnilinstances(): { Instance } ``` ```luau local part = Instance.new("Part") part.Parent = nil for _, inst in pairs(getinstances()) do if inst == part then print("Found nil-parented part via getinstances!") end end for _, inst in pairs(getnilinstances()) do if inst == part then print("Found our unattached part via getnilinstances!") end end ``` -------------------------------- ### Basic GET Request with Fingerprint Lookup Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Miscellaneous/request.md Perform a basic GET request and inspect headers for a fingerprint. Ensure HttpService is available. ```luau local response = request({ Url = "http://httpbin.org/get", Method = "GET", }) local decoded = game:GetService("HttpService"):JSONDecode(response.Body) local retrieved_fingerprint for key in pairs(decoded.headers) do if key:match("Fingerprint") then retrieved_fingerprint = key break end end print(response.StatusCode) -- Output: 200 print(response.Success) -- Output: true print(retrieved_fingerprint) -- Output: PREFIX-Fingerprint ``` -------------------------------- ### getgenv Usage Example Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Environment/getgenv.md Demonstrates that `getgenv` is not affected by modifications to the global table or `getfenv`. It shows how to set and access values within the executor's global environment. ```luau getgenv().dummy_val = "value" getfenv().dummy_val_2 = 1 print(dummy_val, getgenv().dummy_val_2) -- Output: value, nil getgenv().dummy_val = "value2" dummy_val = nil print(dummy_val) -- Output: value2 ``` -------------------------------- ### Modify Upvalue and Observe Change Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Illustrates using `debug.setupvalue` to change an upvalue of a function and then executing the function to observe the modified behavior. The example shows incrementing a captured variable and then setting it to a new value. ```luau local upvalue = 90 local function dummy_function() upvalue += 1 print(upvalue) end dummy_function() -- Output: 91 debug.setupvalue(dummy_function, 1, 99) dummy_function() -- Output: 100 ``` -------------------------------- ### Delete a file using `delfile` Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Filesystem/delfile.md Use `delfile` to remove a file. This example demonstrates creating a file, verifying its existence, deleting it, and then verifying its absence. ```luau writefile("file5.txt", "Hello") print(isfile("file5.txt")) -- Output: true delfile("file5.txt") print(isfile("file5.txt")) -- Output: false ``` -------------------------------- ### Retrieve multiple values from the stack Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Debug/getstack.md This example demonstrates retrieving multiple values from the current stack level recursively. Ensure the stack level and index are valid to avoid errors. ```luau local count = 0 local function recursive_function() count += 1 if count > 6 then return end local a = 29 local b = true local c = "Example" a += 1 b = false c ..= "s" print(debug.getstack(1, count)) recursive_function() end recursive_function() -- Output (varies depending on Count): -- 30 -- false -- Examples -- function: 0x... (print) -- function: 0x... (getstack) -- etc. ``` -------------------------------- ### Replicate ClickDetector MouseActionReplicated Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Signals/replicatesignal.md This example demonstrates how to replicate a `ClickDetector`'s `MouseActionReplicated` signal to the server. Ensure the arguments match the signal's expected parameters. The `task.wait` is used to allow the replication to process. ```luau local detector = workspace.replicatesigmal.ClickDetector replicatesignal(detector.MouseActionReplicated, game.Players.LocalPlayer, 0) task.wait(0.1) print(game.Players.LocalPlayer:GetAttribute("MouseClickReplicated")) -- Output: true ``` -------------------------------- ### WebSocket.connect Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/WebSocket/README.md Attempts to create a new connection to the provided WebSocket server URL. The URL must start with `ws://` or `wss://`. ```APIDOC ## WebSocket.connect ### Description Attempts to create a new connection to the provided URL. The URL must be a valid WebSocket server URL, typically starting with `ws://` (unsecure) or `wss://` (secure). ### Method `WebSocket.connect(url: string): WebSocket` ### Parameters #### Path Parameters - **url** (string) - Required - A WebSocket URL. ``` -------------------------------- ### Restoring a hooked function in Luau Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Closures/restorefunction.md Demonstrates how to use `restorefunction` to revert a function to its original state after it has been hooked. This example shows the output before and after restoration. ```luau function dummy_func() print("I am not hooked!") end hookfunction(dummy_func, function() print("I am hooked!") end) dummy_func() restorefunction(dummy_func) dummy_func() ``` -------------------------------- ### Draw and Destroy a Circle Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Example of creating a 'Circle' drawing object, configuring its properties (Radius, Color, Position, etc.), displaying it, and then destroying it. It also shows how to check if the object still exists after destruction. ```luau local Camera = game.Workspace.CurrentCamera local Viewport = Camera.ViewportSize local Center = Vector2.new(Viewport.X / 2, Viewport.Y / 2) -- Draw a filled red circle at the center of the screen: local circle = Drawing.new("Circle") circle.Radius = 50 circle.Color = Color3.fromRGB(255, 0, 0) circle.Filled = true circle.NumSides = 150 circle.Position = Center circle.Transparency = 0 circle.Visible = true print(circle.__OBJECT_EXISTS) -- Output: true task.wait(2) circle:Destroy() print(circle.__OBJECT_EXISTS) -- Output: false ``` -------------------------------- ### Inspecting and Invoking a Luau Connection Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Signals/getconnections.md Demonstrates how to get the first connection from a Luau signal, invoke its associated function directly using `Function()` or `Fire()`, and inspect its `Thread` property. ```luau local folder = Instance.new("Folder") folder.ChildAdded:Connect(function() print("Triggered") end) local connection = getconnections(folder.ChildAdded)[1] -- First connection in the list connection.Function() -- Output: Triggered connection:Fire() -- Same as above, Output: Triggered print(typeof(connection.Thread)) -- Output: thread ``` -------------------------------- ### Locate a Specific Script Instance Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Scripts/getscripts.md Iterate through the scripts returned by `getscripts` to find a particular instance. This example demonstrates how to locate a dynamically created script. ```luau local dummy_script = Instance.new("LocalScript") dummy_script.Name = "TestScript" for _, script in pairs(getscripts()) do if script == dummy_script then print("Found the dummy script!") end end ``` -------------------------------- ### Get All Instances (Luau) Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Instances/getinstances.md This function retrieves every `Instance` from the registry, including those parented to `nil`. Use this when you need to access instances that may not be part of the standard game hierarchy. ```Luau function getinstances(): { Instance } ``` -------------------------------- ### Simulate Touched Event with true/false Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Instances/firetouchinterest.md Use `true` to simulate the start of a touch event and `false` to simulate the end. Ensure the `Touched` event is connected to observe the simulation. ```luau function firetouchinterest(part1: BasePart, part2: BasePart, toggle: boolean | number): () ``` ```luau local dummy_part = Instance.new("Part") dummy_part.CFrame = CFrame.new(0, -200, 0) dummy_part.Anchored = true dummy_part.Parent = workspace dummy_part.Touched:Connect(function(part) print(part.Name .. " touched the dummy part!") end) local player_head = game.Players.LocalPlayer.Character.Head firetouchinterest(player_head, dummy_part, true) -- Simulate touch task.wait(0.5) firetouchinterest(player_head, dummy_part, false) -- Simulate un-touch ``` -------------------------------- ### Connect to WebSocket Server Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/WebSocket/README.md Establishes a new WebSocket connection to the specified URL. The URL must be a valid WebSocket server address, starting with `ws://` or `wss://`. ```luau function WebSocket.connect(url: string): WebSocket ``` -------------------------------- ### Retrieve Script Closure Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Scripts/getscriptclosure.md This example demonstrates how to retrieve a function closure from a `LocalScript` instance and prints its type. It also shows that `getscriptclosure` returns `nil` for a newly created `LocalScript` without bytecode. ```luau local animate = game.Players.LocalPlayer.Character:FindFirstChild("Animate") local closure = getscriptclosure(animate) print(typeof(closure)) -- Output: function 0x.... print(getscriptclosure(Instance.new("LocalScript"))) -- Output: nil ``` -------------------------------- ### Enumerate Scripts with getscripts, getrunningscripts, getloadedmodules Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Get all script instances, currently active scripts, or only require'd ModuleScripts. Useful for iterating and identifying specific scripts. ```luau function getscripts(): { BaseScript | ModuleScript } function getrunningscripts(): { BaseScript | ModuleScript } function getloadedmodules(): { ModuleScript } ``` ```luau local dummy = Instance.new("LocalScript") dummy.Name = "TestScript" for _, s in pairs(getscripts()) do if s == dummy then print("Found TestScript in getscripts") end end local animate = game.Players.LocalPlayer.Character:FindFirstChild("Animate") for _, s in pairs(getrunningscripts()) do if s == animate then print("Animate is running!") end end local loaded = Instance.new("ModuleScript") local not_loaded = Instance.new("ModuleScript") pcall(require, loaded) for _, m in pairs(getloadedmodules()) do if m == loaded then print("Found loaded module") end if m == not_loaded then print("Should never appear") end end ``` -------------------------------- ### Simulate Touched Event with 0/1 Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Instances/firetouchinterest.md Use `0` to simulate the start of a touch event and `1` to simulate the end. This provides an alternative to using boolean values for the toggle parameter. ```luau local dummy_part = Instance.new("Part") dummy_part.CFrame = CFrame.new(0, -200, 0) dummy_part.Anchored = true dummy_part.Parent = workspace dummy_part.Touched:Connect(function(part) print(part.Name .. " touched the dummy part!") end) local player_head = game.Players.LocalPlayer.Character.Head firetouchinterest(player_head, dummy_part, 0) -- Simulate touch task.wait(0.5) firetouchinterest(player_head, dummy_part, 1) -- Simulate un-touch ``` -------------------------------- ### Hooking `__index` Metamethod with `hookmetamethod` Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Closures/hookmetamethod.md This example demonstrates how to use `hookmetamethod` to hook the `__index` metamethod of the `game` object. It prints the accessed key and then restores the original `__index` behavior. Ensure `hookfunction` is implemented in C++ for this to work. ```luau local original; original = hookmetamethod(game, "__index", function(...) local key = select(2, ...) print(key) return original(...) end) local _ = game.PlaceId -- Output: "PlaceId" hookmetamethod(game, "__index", original) -- Restores game's __index ``` -------------------------------- ### Handle Incorrect Argument Usage with replicatesignal Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Signals/replicatesignal.md This example shows how `replicatesignal` throws an error when incorrect arguments are provided for a signal, specifically `MouseWheelForward`. It also demonstrates a successful replication with the correct arguments. Use `task.wait` to allow the replication to complete. ```luau local ui_frame = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame -- These will throw an error. replicatesignal(ui_frame.MouseWheelForward) replicatesignal(ui_frame.MouseWheelForward, 121) -- This succeeds replicatesignal(ui_frame.MouseWheelForward, 121, 214) task.wait(0.1) print(game.Players.LocalPlayer:GetAttribute("MouseWheelForwardReplicated")) -- Output: true ``` -------------------------------- ### Checking if a Module Has Been Loaded Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Scripts/getloadedmodules.md This example demonstrates how to use `getloadedmodules` to check if a specific ModuleScript has been loaded. It iterates through the returned modules and compares them to known ModuleScript instances. ```luau local loaded = Instance.new("ModuleScript") local not_loaded = Instance.new("ModuleScript") pcall(require, loaded) for _, module in pairs(getloadedmodules()) do if module == loaded then -- The first modulescript was found because it was required in line 4 print("Found loaded module!") elseif module == notLoaded then -- The second modulescript should NOT be found because it was never required print("This should never appear.") end end ``` -------------------------------- ### Retrieve upvalues from a closure Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Debug/getupvalues.md This example demonstrates how to retrieve and print the upvalues of a closure. It initializes two variables, `var1` and `var2`, which are then captured by `dummy_function`. The `debug.getupvalues` function is called on `dummy_function`, and the resulting upvalues are iterated through and printed. ```luau local var1 = false local var2 = "Hi" local function dummy_function() var1 = true var2 ..= ", hello" end for index, value in pairs(debug.getupvalues(dummy_function)) do print(index, value) end ``` -------------------------------- ### Firing different ClickDetector events Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Instances/fireclickdetector.md This example demonstrates how to use `fireclickdetector` to trigger various events on a `ClickDetector`. It sets up connections for `MouseClick`, `RightMouseClick`, `MouseHoverEnter`, and `MouseHoverLeave` events, then calls `fireclickdetector` to simulate each event. ```luau local click_detector = Instance.new("ClickDetector") click_detector.MouseClick:Connect(function(player) print(`{player.Name} Fired M1`) end) click_detector.RightMouseClick:Connect(function(player) print(`{player.Name} Fired M2`) end) click_detector.MouseHoverEnter:Connect(function(player) print(`{player.Name} Fired HoverEnter`) end) click_detector.MouseHoverLeave:Connect(function(player) print(`{player} Fired HoverLeave`) end) fireclickdetector(click_detector, 0, "MouseClick") -- Output: Player Fired M1 fireclickdetector(click_detector, 0, "RightMouseClick") -- Output: Player Fired M2 fireclickdetector(click_detector, 0, "MouseHoverEnter") -- Output: Player Fired HoverEnter fireclickdetector(click_detector, 0, "MouseHoverLeave") -- Output: Player Fired HoverLeave ``` -------------------------------- ### Clear All Drawing Objects Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Drawing/cleardrawcache.md This example demonstrates how to create a drawing object and then clear all active drawing objects using `cleardrawcache`. It shows that the object exists before the call and is removed afterward. ```luau local camera = game.Workspace.CurrentCamera local viewport = camera.ViewportSize local pos = Vector2.new(viewport.X / 2, viewport.Y / 2) local circle = Drawing.new("Circle") circle.Radius = 50 circle.Color = Color3.fromRGB(255, 0, 0) circle.Filled = true circle.NumSides = 60 circle.Position = pos circle.Transparency = 1 circle.Visible = true task.defer(cleardrawcache) print(circle.__OBJECT_EXISTS) -- Output: true task.wait() print(circle.__OBJECT_EXISTS) -- Output: false ``` -------------------------------- ### Get an out-of-range constant from a Luau function Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Debug/getconstant.md This example shows the behavior when requesting a constant at an index that does not exist within the function. It will return nil. ```luau local function dummy_function() local dummy_string = "foo bar" string.split(dummy_string, " ") end local result = debug.getconstant(dummy_function, 3) print(result) -- Output: nil ``` -------------------------------- ### Get a valid constant from a Luau function Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Debug/getconstant.md This example demonstrates retrieving a constant that exists within the function's scope. The output will be the value of the constant at the specified index. ```luau local function dummy_function() local dummy_string = "foo bar" string.split(dummy_string, " ") end local result = debug.getconstant(dummy_function, 2) print(result) -- Output: string ``` -------------------------------- ### Access and Inspect Nested Functions Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Demonstrates using `debug.getprotos` to iterate through nested function prototypes and `debug.info` to get their names. It also shows how to retrieve an active instance of a nested function using `debug.getproto` with `activated = true`. ```luau local function DummyFunction0() local function DummyFunction1() end local function DummyFunction2() end end for index, proto in pairs(debug.getprotos(DummyFunction0)) do print(index, debug.info(proto, "n")) end -- Output: -- 1 DummyFunction1 -- 2 DummyFunction2 -- Retrieve an active instance of a proto: local function outer() local function inner() return "hi" end return inner end local real_inner = outer() local retrieved = debug.getproto(outer, 1, true)[1] print(real_inner == retrieved) -- Output: true print(retrieved()) -- Output: hi ``` -------------------------------- ### Compare Instances Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Instances/compareinstances.md Demonstrates comparing instances for equality, including cases with `cloneref`. Use `compareinstances` for accurate equality checks on potentially cloned instances, as `==` may fail. ```luau function compareinstances(object1: Instance, object2: Instance): boolean end ``` ```luau print(compareinstances(game, game)) print(compareinstances(game, workspace)) print(compareinstances(game, cloneref(game))) print(game == cloneref(game)) ``` -------------------------------- ### Get Specific Nested Function Prototype Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Retrieves a specific nested function prototype by its index. The `activated` parameter can be used to get active function instances instead of prototypes. ```luau function debug.getproto(func: (...any) -> (...any) | number, index: number, activated: boolean?): (...any) -> (...any) | { (...any) -> (...any) } ``` -------------------------------- ### Create Folder Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Filesystem/makefolder.md Use `makefolder` to create a new directory. Verify its creation using `isfolder`. This function is useful for organizing files. ```luau function makefolder(path: string): () ``` ```luau makefolder("test_folder") print(isfolder("test_folder")) -- Output: true ``` -------------------------------- ### getrawmetatable Function Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Metatable/getrawmetatable.md This snippet details the getrawmetatable function, its parameters, and provides examples of its usage. ```APIDOC ## getrawmetatable `#!luau getrawmetatable` returns the raw metatable of an object, even if that object has a `#!luau __metatable` field set. ```luau function getrawmetatable(object: { any } | userdata): { [any]: any } | nil ``` ### Parameters | Parameter | Description | | --------------- | --------------------------------------- | | `#!luau object` | The object whose metatable to retrieve. | --- ### Examples #### Example 1: Retrieving the metatable of the DataModel ```luau title="Retrieving the metatable of the DataModel" linenums="1" local mt = getrawmetatable(game) print(type(mt)) -- Output: table print(mt.__index(game, "Workspace")) -- Output: Workspace ``` #### Example 2: Obtaining nil when object has no metatable set ```luau title="Obtaining nil when object has no metatable set" linenums="1" print(getrawmetatable(newproxy(false))) -- Output: nil ``` ``` -------------------------------- ### Hooking functions with hookfunction Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Closures/hookfunction.md Demonstrates how to replace a function's behavior with a hook and how to call the original function using the returned reference. ```luau local function dummy_func() print("I am not hooked!") end local function dummy_hook() print("I am hooked!") end dummy_func() -- Output: I am not hooked! local old_func = hookfunction(dummy_func, dummy_hook) dummy_func() -- Output: I am hooked! old_func() -- Output: I am not hooked! ``` -------------------------------- ### Get All Upvalues of a Function Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Retrieves all upvalues captured by a function. Useful for inspecting the closure's environment. ```luau function debug.getupvalues(func: (...any) -> (...any) | number): { any } ``` -------------------------------- ### Load and Execute a Valid File with `loadfile` Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Filesystem/loadfile.md Demonstrates loading a Lua file using `loadfile` and then executing the returned chunk with an argument. Ensure the file exists and contains valid Luau code. ```luau writefile("file6.lua", "return 10 + ...") local chunk = loadfile("file6.lua") print(chunk(1)) -- Output: 11 ``` -------------------------------- ### Get Connections for RBXScriptSignal Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Signals/getconnections.md This is the function signature for `getconnections`. It takes an `RBXScriptSignal` as input and returns a table of `Connection` objects. ```luau function getconnections(signal: RBXScriptSignal): {Connection} ``` -------------------------------- ### Checking SHA384 Hash of Functions with `getfunctionhash` Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Closures/getfunctionhash.md This example demonstrates how to use `getfunctionhash` to verify the SHA384 hash of different functions. It includes a helper function `is_sha384_hex` to validate the hash format. Note that functions with identical code but different constant return values will produce different hashes. ```luau local function is_sha384_hex(hash) return #hash == 96 and hash:match("^[0-9a-fA-F]+$") ~= nil end local dummy_function_0 = function() end local dummy_function_1 = function(...) end local dummy_function_2 = function() end local dummy_function_3 = function() return "Constant" end local dummy_function_4 = function() return "Constant2" end print(is_sha384_hex(getfunctionhash(dummy_function_0))) -- Output: true print(getfunctionhash(dummy_function_0) == getfunctionhash(dummy_function_1)) -- Output: false print(getfunctionhash(dummy_function_0) == getfunctionhash(dummy_function_2)) -- Output: true print(getfunctionhash(dummy_function_3) == getfunctionhash(dummy_function_4)) -- Output: false ``` -------------------------------- ### Load and Display an Image Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Demonstrates creating an 'Image' drawing object, loading image data from a local file using `readfile`, setting its size and position, and making it visible. The image is then destroyed after a delay. ```luau -- Load and display a local image file: local image = Drawing.new("Image") image.Data = readfile("your_image.png") image.Size = Vector2.new(455, 155) image.Position = Center image.Visible = true task.wait(2) image:Destroy() ``` -------------------------------- ### Get All Scripts Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Scripts/getscripts.md Use this function to retrieve a list of all Script, LocalScript, and ModuleScript instances. It excludes CoreScripts by default. ```luau function getscripts(): { BaseScript | ModuleScript } ``` -------------------------------- ### Get Roblox Global Environment Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Environment/getrenv.md This function retrieves the Roblox global environment. Modifying this environment can affect the executor. ```luau function getrenv(): { any } ``` -------------------------------- ### Line Drawing Properties Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Drawing/README.md Properties specific to the Line drawing type, defining its start and end points, and thickness. ```luau -- From: Start position of the line. -- To: End position of the line. -- Thickness: Width of the line. ``` -------------------------------- ### Get Loaded Modules Function Signature Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Scripts/getloadedmodules.md This is the function signature for `getloadedmodules`. It takes no parameters and returns a table of ModuleScript objects. ```luau function getloadedmodules(): { ModuleScript } ``` -------------------------------- ### Filesystem Utilities Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Manage directories and files using functions like `makefolder`, `isfile`, `isfolder`, `listfiles`, `delfile`, and `delfolder`. ```luau function isfile(path: string): boolean function isfolder(path: string): boolean function makefolder(path: string): () function listfiles(path: string): { string } function delfile(path: string): () function delfolder(path: string): () ``` ```luau makefolder("test_folder") print(isfolder("test_folder")) -- Output: true writefile("test_folder/data.txt", "data") print(isfile("test_folder/data.txt")) -- Output: true print(isfile("nonexistent.txt")) -- Output: false for _, file in listfiles("test_folder") do print(file) -- Output: test_folder/data.txt end delfile("test_folder/data.txt") print(isfile("test_folder/data.txt")) -- Output: false delfolder("test_folder") print(isfolder("test_folder")) -- Output: false ``` -------------------------------- ### Get Specific Upvalue by Index Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Retrieves the upvalue at a specific index for a given function. Ensure the index is valid to avoid errors. ```luau function debug.getupvalue(func: (...any) -> (...any) | number, index: number): any ``` -------------------------------- ### Retrieve Metatable of DataModel Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Metatable/getrawmetatable.md Use `getrawmetatable` to get the metatable of the `game` object. This demonstrates retrieving the metatable and accessing its `__index` metamethod. ```luau local mt = getrawmetatable(game) print(type(mt)) -- Output: table print(mt.__index(game, "Workspace")) -- Output: Workspace ``` -------------------------------- ### Function Documentation Format Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/About/contributing.md This snippet details the required structure for documenting functions, emphasizing type definitions, parameter formatting, and example inclusion. ```APIDOC ## Description Provide a description of the function directly after any notices. When referencing the function name, **always** use the code snippet format: ```md `#!luau function_name` allows you to do this and that. ``` --- ### Type definition !!! info "Type definitions are important!" You **must** always include a Luau-style type definition when documenting a function. Include the Luau type definition **at the bottom of the first section**, with Luau syntax highlighting but **no *individual line highlighting* or line numbers**: ```luau function newcclosure(functionToWrap: (A...) -> R...): (A...) -> R... ``` Make sure it precedes the parameters table. --- ### Parameters The parameters must always be neatly described in a function, like so: ```md ## Parameters | Parameter | Description | | ----------------------- | ----------------------------------- | | `#!luau parameter_name` | Short description of the parameter. | ``` Use [**snake_case**](https://en.wikipedia.org/wiki/Snake_case) for **every variable**, and [**camelCase**](https://en.wikipedia.org/wiki/Camel_case) for **parameters** to easily distinguish between the two. There should be **no horizontal rule** (`---`) between the *type definition* and the *parameters* section. --- ### Providing users with examples Every function page **must** include at least one example. !!! info "Use 'Example' or 'Examples' based on how many examples you have" To make the documentation experience more logical and also grammatically correct, please do the following: - Make the heading `#!md ## Example` if there is only one example. - Make the heading `#!md ## Examples` if there is more than one example. Each example should have its own subheading, e.g. `#!md ### Example 1`, `#!md ### Example 2`. Each example should use the following format: ````md ## Example ```luau title="Short but descriptive title for your code" linenums="1" -- an example is here print("Hello world!") print("This is some example code") ``` ```` - Examples must use `luau` syntax highlighting. - Line numbers **must** be enabled using `linenums="1"`. - Each example **must** have a `title` describing in short what the code does. ``` -------------------------------- ### Get Current Namecall Method Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Must be called from inside a `__namecall` hook. Returns the method name being called, or nil outside such a hook. ```Luau function getnamecallmethod(): string? ``` ```Luau local refs = {} refs.__namecall = hookmetamethod(game, "__namecall", function(...) local self = ... local method = getnamecallmethod() if self == game and method == "service" then error("Using game:service() is not allowed.") end return refs.__namecall(...) end) ``` -------------------------------- ### Get Executor Name and Version Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Miscellaneous/identifyexecutor.md Use this snippet to retrieve and print the name and version of the current executor. This is helpful for logging or debugging purposes. ```luau function identifyexecutor(): (string, string) end ``` ```luau local exec_name, exec_version = identifyexecutor() print(exec_name, exec_version) -- Output: "YourExploitName 0.0.1" ``` -------------------------------- ### Replace Numeric Upvalue with debug.setupvalue Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Debug/setupvalue.md Demonstrates how to replace a numeric upvalue within a function using debug.setupvalue. The function's behavior changes after the upvalue is modified. ```luau local upvalue = 90 local function dummy_function() upvalue += 1 print(upvalue) end dummy_function() -- Output: 91 debug.setupvalue(dummy_function, 1, 99) dummy_function() -- Output: 100 ``` -------------------------------- ### Iterate and Print Function Upvalues Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Demonstrates iterating through all upvalues of a function using `debug.getupvalues` and printing their index and value. Also shows how to retrieve and execute a specific upvalue using `debug.getupvalue`. ```luau local var1 = false local var2 = "Hi" local function dummy_function() var1 = true var2 ..= ", hello" end for index, value in pairs(debug.getupvalues(dummy_function)) do print(index, value) end -- Output: -- 1 false -- 2 Hi local UpFunction = function() print("Hello from up") end local function DummyFunction() UpFunction() end debug.getupvalue(DummyFunction, 1)() -- Output: Hello from up ``` -------------------------------- ### Get Custom Asset Function Signature Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Filesystem/getcustomasset.md This is the function signature for `getcustomasset`. It takes a string representing the file path and returns a string which is the asset ID. ```luau function getcustomasset(path: string): string ``` -------------------------------- ### makefolder Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Filesystem/makefolder.md Creates a folder at the specified path. Useful for organizing files into separate directories. ```APIDOC ## makefolder ### Description Creates a folder at the specified path if one does not already exist. This is useful for organising files into separate directories. ### Signature `function makefolder(path: string): ()` ### Parameters #### Path Parameters - **path** (string) - Required - The folder path to create. ### Example ```luau makefolder("test_folder") print(isfolder("test_folder")) -- Output: true ``` ``` -------------------------------- ### getinstances() Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Instances/getinstances.md Retrieves every Instance from the registry, including those parented to nil. ```APIDOC ## getinstances() ### Description Retrieves every Instance from the registry, including those that are or were parented to `nil`. ### Method `getinstances()` ### Parameters This function takes no parameters. ### Response Returns a table containing all tracked `Instance` objects. ### Example ```luau title="Finding a nil-parented instance" linenums="1" local dummy_part = Instance.new("Part") dummy_part.Parent = nil for _, instance in pairs(getinstances()) do if instance == dummy_part then print("Found the dummy part!") end end ``` ``` -------------------------------- ### Basic File I/O Operations Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Perform fundamental file operations: `writefile` to create/overwrite, `readfile` to retrieve content, and `appendfile` to add data to existing files. ```luau function writefile(path: string, data: string): () function readfile(path: string): string function appendfile(path: string, contents: string): () ``` ```luau writefile("file.txt", "Hello world") print(readfile("file.txt")) -- Output: Hello world appendfile("file.txt", "!!!") print(readfile("file.txt")) -- Output: Hello world!!! writefile("script.lua", "print(") appendfile("script.lua", "'Hi')") print(readfile("script.lua")) -- Output: print('Hi') ``` -------------------------------- ### firetouchinterest Function Source: https://github.com/sunc-utilities/docs.sunc.su/blob/main/docs/Instances/firetouchinterest.md Simulates a physical touch event between two BasePart objects. It can emulate both the start and end of a Touched event. Avoid implementing this function in Luau. ```APIDOC ## `firetouchinterest` !!! warning "Avoid implementing in Luau" This function should **not be implemented** in Luau. Doing so exposes you to easy detection vectors. `#!luau firetouchinterest` simulates a physical touch event between two [`#!luau BasePart`](https://create.roblox.com/docs/reference/engine/classes/BasePart) objects. It can emulate both the start and end of a [`#!luau Touched`](https://create.roblox.com/docs/reference/engine/classes/BasePart#Touched) event. ```luau function firetouchinterest(part1: BasePart, part2: BasePart, toggle: boolean | number): () ``` ### Parameters | Parameter | Description | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------- | | `#!luau part1` | The initiating [`#!luau BasePart`](https://create.roblox.com/docs/reference/engine/classes/BasePart). | | `#!luau part2` | The [`#!luau BasePart`](https://create.roblox.com/docs/reference/engine/classes/BasePart) that should be touched. | | `#!luau toggle` | Whether to simulate touch start or end. `#!luau true` or `#!luau 0` simulates touch; `#!luau false` or `#!luau 1` simulates un-touch. | --- ### Examples #### Example 1: Simulating a Touched event using 'true/false' ```luau title="Simulating a Touched event using 'true/false'" linenums="1" local dummy_part = Instance.new("Part") dummy_part.CFrame = CFrame.new(0, -200, 0) dummy_part.Anchored = true dummy_part.Parent = workspace dummy_part.Touched:Connect(function(part) print(part.Name .. " touched the dummy part!") end) local player_head = game.Players.LocalPlayer.Character.Head firetouchinterest(player_head, dummy_part, true) -- Simulate touch task.wait(0.5) firetouchinterest(player_head, dummy_part, false) -- Simulate un-touch ``` #### Example 2: Simulating a Touched event using '0/1' ```luau title="Simulating a Touched event using '0/1'" linenums="1" local dummy_part = Instance.new("Part") dummy_part.CFrame = CFrame.new(0, -200, 0) dummy_part.Anchored = true dummy_part.Parent = workspace dummy_part.Touched:Connect(function(part) print(part.Name .. " touched the dummy part!") end) local player_head = game.Players.LocalPlayer.Character.Head firetouchinterest(player_head, dummy_part, 0) -- Simulate touch task.wait(0.5) firetouchinterest(player_head, dummy_part, 1) -- Simulate un-touch ``` ``` -------------------------------- ### Instances Library Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Provides direct access to and manipulation of Roblox Instance objects. ```APIDOC ## Instances Library Provides direct access to and manipulation of Roblox Instance objects. ### `getinstances` / `getnilinstances` #### Description Enumerates game instances. `getinstances()` returns all instances, while `getnilinstances()` returns only currently unparented instances. #### Method - `getinstances(): { Instance }` - `getnilinstances(): { Instance }` #### Request Example ```luau local part = Instance.new("Part") part.Parent = nil for _, inst in pairs(getinstances()) do if inst == part then print("Found nil-parented part via getinstances!") end end for _, inst in pairs(getnilinstances()) do if inst == part then print("Found our unattached part via getnilinstances!") end end ``` ``` -------------------------------- ### Get All Nested Function Prototypes Source: https://context7.com/sunc-utilities/docs.sunc.su/llms.txt Retrieves all nested function prototypes defined within the bytecode of a given function. This allows introspection of the function's internal structure. ```luau function debug.getprotos(func: (...any) -> (...any) | number): { (...any) -> (...any) } ```