### Perform a GET Request Source: https://docs.voltbz.net/docs/miscellaneous/request A simple example demonstrating how to perform a GET request and check for success. ```lua local response = request({ Url = "https://httpbin.org/get", Method = "GET" }) if response.Success then print("Status:", response.StatusCode) print("Body:", response.Body) end ``` -------------------------------- ### Example output for getsignalargumentsinfo Source: https://docs.voltbz.net/docs/signals/getsignalargumentsinfo Shows the expected console output when running the example code for the PlayerAdded signal. ```text PlayerAdded arguments: 1. player: Instance ``` -------------------------------- ### setrbxclipboard Usage Example Source: https://docs.voltbz.net/docs/miscellaneous/setrbxclipboard A basic example demonstrating how to copy a string to the internal Studio clipboard. ```luau setrbxclipboard("Text for the Studio clipboard") ``` -------------------------------- ### Delete a file example Source: https://docs.voltbz.net/docs/filesystem/delfile Demonstrates creating, verifying, and deleting a file. ```lua -- Create a file writefile("temp.txt", "Temporary data") -- Verify it exists print(isfile("temp.txt")) -- true -- Delete it delfile("temp.txt") -- Verify it's gone print(isfile("temp.txt")) -- false ``` -------------------------------- ### rconsoleinfo Usage Example Source: https://docs.voltbz.net/docs/console/rconsoleinfo Demonstrates initializing the console and printing informational messages. ```lua rconsoleshow() rconsoleinfo("Script loaded successfully") rconsoleinfo("Found 5 players in game") ``` -------------------------------- ### mouse2click Usage Example Source: https://docs.voltbz.net/docs/input/mouse2click Demonstrates how to trigger a right click to open a context menu. ```text -- Right click to open context menu mouse2click() ``` -------------------------------- ### getfflag Usage Examples Source: https://docs.voltbz.net/docs/miscellaneous/getfflag Examples demonstrating how to retrieve a numeric Fast Flag and check a boolean-like feature flag. ```lua -- Get current target FPS local fps = getfflag("DFIntTaskSchedulerTargetFps") print("Target FPS:", fps) -- Check if a feature is enabled local enabled = getfflag("FFlagSomeFeature") print("Feature enabled:", enabled == "true") ``` -------------------------------- ### Save Instance Example Source: https://docs.voltbz.net/docs/miscellaneous/saveinstance Demonstrates creating a model, configuring save options, and serializing the instance to a file. ```lua local model = Instance.new("Model") model.Name = "ExampleModel" local part = Instance.new("Part") part.Name = "ExamplePart" part.Parent = model local options = SaveInstanceOptions.new() options.FilePath = "exports/example-model.rbxm" options.IgnoreArchivable = false options.DecompileScripts = true saveinstance(model, options) print(isfile("exports/example-model.rbxm")) -- true model:Destroy() ``` -------------------------------- ### Basic File Appending Example Source: https://docs.voltbz.net/docs/filesystem/appendfile Demonstrates creating a file and appending multiple lines of text to it. ```lua -- Create initial file writefile("log.txt", "Log started\n") -- Append entries appendfile("log.txt", "Entry 1: Hello\n") appendfile("log.txt", "Entry 2: World\n") -- Read the result print(readfile("log.txt")) --[[ Log started Entry 1: Hello Entry 2: World ]] ``` -------------------------------- ### rconsoleerr Usage Example Source: https://docs.voltbz.net/docs/console/rconsoleerr Demonstrates how to initialize the console and log error messages. ```javascript rconsoleshow() rconsoleerr("Failed to load module!") rconsoleerr("Connection timed out") ``` -------------------------------- ### Create a Line Overlay Source: https://docs.voltbz.net/docs/drawing Example of instantiating a line object and configuring its visual properties. ```lua local line = Drawing.new("Line") line.From = Vector2.new(0, 0) line.To = Vector2.new(100, 100) line.Color = Color3.fromRGB(255, 0, 0) line.Thickness = 2 line.Visible = true ``` -------------------------------- ### Basic Usage Example Source: https://docs.voltbz.net/docs/scripts/getrunningscripts Retrieves the list of running scripts and prints their count and full names. ```lua local scripts = getrunningscripts() print("Running scripts:", #scripts) for _, script in ipairs(scripts) do print("-", script:GetFullName()) end ``` -------------------------------- ### Iterating over all threads Source: https://docs.voltbz.net/docs/environment/getallthreads Example demonstrating how to retrieve and iterate through all reachable threads. ```Luau local threads = getallthreads() print("Threads found:", #threads) for index, thread in ipairs(threads) do print(index, coroutine.status(thread), getscriptfromthread(thread)) end ``` -------------------------------- ### rconsoleprint Usage Example Source: https://docs.voltbz.net/docs/console/rconsoleprint Demonstrates printing a string and a table to the console. ```lua rconsoleshow() rconsoleprint("Hello, World!") rconsoleprint({ answer = 42 }, false) ``` -------------------------------- ### Basic Folder Creation Examples Source: https://docs.voltbz.net/docs/filesystem/makefolder Demonstrates creating simple and nested folders, followed by verification using isfolder. ```lua -- Create a simple folder makefolder("configs") -- Create nested folders makefolder("data/saves/player1") -- Verify they exist print(isfolder("configs")) -- true print(isfolder("data/saves/player1")) -- true ``` -------------------------------- ### rconsoletop Usage Example Source: https://docs.voltbz.net/docs/console/rconsoletop Demonstrates showing the console, printing a message, and setting the window to stay on top. ```lua rconsoleshow() rconsoleprint("This console is now on top!\n") -- Bring console to front rconsoletop(true) ``` -------------------------------- ### Hooking a Proto Example Source: https://docs.voltbz.net/docs/closures/hookproto Demonstrates how to retrieve a proto using debug.getproto and apply a hook to modify its behavior. ```Luau local function makeGreeter() local function greet(name) return `Hello, {name}!` end return greet end local greet = makeGreeter() local proto = debug.getproto(makeGreeter, 1) hookproto(proto, function(name) return `Hooked: {name}` end) print(greet("Volt")) -- Hooked: Volt print(makeGreeter()("Docs")) -- Hooked: Docs restoreproto(proto) print(greet("Volt")) -- Hello, Volt! ``` -------------------------------- ### Example usage of console functions Source: https://docs.voltbz.net/docs/console/rconsoleshow Demonstrates creating the console, printing a message, and setting a custom title. ```lua -- Create and show the console rconsoleshow() -- Print a welcome message rconsoleprint("Welcome to the console!\n") -- Set a custom title rconsolename("My Script Console") ``` -------------------------------- ### Delete a folder example Source: https://docs.voltbz.net/docs/filesystem/delfolder Demonstrates creating a folder structure, verifying its existence, deleting it, and confirming its removal. ```lua -- Create a folder structure makefolder("testfolder") writefile("testfolder/file1.txt", "Data 1") writefile("testfolder/file2.txt", "Data 2") -- Verify it exists print(isfolder("testfolder")) -- true -- Delete the entire folder delfolder("testfolder") -- Verify it's gone print(isfolder("testfolder")) -- false ``` -------------------------------- ### Basic Base64 Encoding Example Source: https://docs.voltbz.net/docs/encoding/base64encode Demonstrates encoding a standard string into Base64 format. ```lua local data = "Hello, World!" local encoded = base64encode(data) print(encoded) -- "SGVsbG8sIFdvcmxkIQ==" ``` -------------------------------- ### replicatesignal Usage Example Source: https://docs.voltbz.net/docs/signals/replicatesignal Demonstrates firing a ClickDetector's MouseActionReplicated signal to the server. ```lua local Players = game:GetService("Players") local detector = workspace:FindFirstChildWhichIsA("ClickDetector", true) assert(detector, "This example requires a server-created ClickDetector") replicatesignal( detector.MouseActionReplicated, Players.LocalPlayer, 0 ) ``` -------------------------------- ### Hiding the Console Example Source: https://docs.voltbz.net/docs/console/rconsolehide Demonstrates showing the console, printing a message, and hiding it after a delay. ```lua -- Show console and print something rconsoleshow() rconsoleprint("This console will close in 5 seconds...\n") -- Wait and then hide task.wait(5) rconsolehide() ``` -------------------------------- ### mouse1click Usage Examples Source: https://docs.voltbz.net/docs/input/mouse1click Demonstrates performing a single click and a double click sequence. ```lua -- Single click mouse1click() -- Double click mouse1click() task.wait(0.05) mouse1click() ``` -------------------------------- ### WebSocket Connection Example Source: https://docs.voltbz.net/docs/websocket/connect Demonstrates connecting to a server, handling incoming messages, managing connection closure, and sending data. ```lua -- Replace this with a WebSocket endpoint you control local ws = WebSocket.connect("wss://your-server.example/socket") -- Handle incoming messages ws.OnMessage:Connect(function(message, isBinary) print("Received:", message, "binary:", isBinary) end) -- Handle connection close ws.OnClose:Connect(function() print("Connection closed") end) -- Send a message ws:Send("Hello, WebSocket!") ``` -------------------------------- ### setclipboard Usage Examples Source: https://docs.voltbz.net/docs/miscellaneous/setclipboard Demonstrates copying simple strings, player properties, and JSON-encoded tables to the clipboard. ```lua -- Copy a simple message setclipboard("Hello, World!") -- Copy player information local player = game.Players.LocalPlayer setclipboard(player.Name .. " - " .. player.UserId) -- Copy a table as JSON local HttpService = game:GetService("HttpService") local data = {name = "Player", score = 100} setclipboard(HttpService:JSONEncode(data)) ``` -------------------------------- ### Waiting for a Signal Source: https://docs.voltbz.net/docs/voltsignal/wait Example demonstrating how to yield a thread until a signal is fired with arguments. ```lua local signal = VoltSignal.new() -- In another thread, fire after 2 seconds task.spawn(function() task.wait(2) signal:Fire("Data loaded!", 100) end) -- Wait for the signal local message, value = signal:Wait() print(message, value) -- Output (after 2 seconds): Data loaded! 100 ``` -------------------------------- ### Set Console Title Example Source: https://docs.voltbz.net/docs/console/rconsolename Demonstrates initializing the console, setting a custom title, and printing a message. ```lua rconsoleshow() -- Set a custom title rconsolename("My Script v1.0") rconsoleprint("Console is ready!\n") ``` -------------------------------- ### Decompile Raw Bytecode Source: https://docs.voltbz.net/docs/scripts/decompile Example showing how to retrieve raw bytecode from a script and decompile it directly. ```luau local module = assert(getloadedmodules()[1]) local bytecode = getscriptbytecode(module) local source = decompile(bytecode) print(source) ``` -------------------------------- ### Usage Examples for keyclick Source: https://docs.voltbz.net/docs/input/keyclick Demonstrates single key clicks and repeated key clicks using a loop. ```lua -- Click the E key keyclick(0x45) -- Click space multiple times for i = 1, 5 do keyclick(0x20) task.wait(0.1) end ``` -------------------------------- ### Usage example for clearqueueonteleport Source: https://docs.voltbz.net/docs/miscellaneous/clearqueueonteleport Demonstrates queuing a script and subsequently clearing the queue before execution. ```lua -- Queue a script queueonteleport("print('Hello after teleport')") -- Change our mind clearqueueonteleport() -- Now nothing will run after teleporting ``` -------------------------------- ### sethiddenproperty Usage Example Source: https://docs.voltbz.net/docs/reflection/sethiddenproperty Demonstrates setting a property on a Part instance and checking the return value. ```lua local part = Instance.new("Part") local wasHidden = sethiddenproperty(part, "Transparency", 0.5) print(part.Transparency) -- 0.5 print(wasHidden) -- false, because Transparency is normally scriptable ``` -------------------------------- ### Decompile a ModuleScript Source: https://docs.voltbz.net/docs/scripts/decompile Example demonstrating how to configure decompiler options and process a loaded ModuleScript. ```luau local module = getloadedmodules()[1] assert(module, "No loaded ModuleScript was available") local options = DecompilerOptions.new() options.SmartVariableRenamer = true options.GuardClauses = true options.Formatter.IndentWidth = 4 options.Formatter.ColumnLimit = 100 options.Formatter.FunctionMetadataEnabled = true options.Formatter.FunctionMetadataLayout = DecompilerFormatter.FunctionMetadata.Layout.Block local success, sourceOrError = pcall(decompile, module, options) if success then print(sourceOrError) else warn("Decompilation failed:", sourceOrError) end ``` -------------------------------- ### Bidirectional Communication Source: https://docs.voltbz.net/docs/actors/create_comm_channel Example of setting up a channel to receive a response from an actor. ```lua -- Main thread local id, channel = create_comm_channel() channel.Event:Connect(function(response) print("Actor responded:", response) end) local actor = assert(getactors()[1], "No active actor state") run_on_actor(actor, [[ local id = ... local channel = get_comm_channel(id) channel:Fire("Message received!") ]], id) ``` -------------------------------- ### Using gettenv Source: https://docs.voltbz.net/docs/environment/gettenv Examples showing how to retrieve the environment for the current thread and a newly created coroutine thread. ```lua -- Get current thread's environment local env = gettenv() print(env.print) -- The print function -- Get another thread's environment local thread = coroutine.create(function() end) local threadEnv = gettenv(thread) print(threadEnv ~= nil) -- true ``` -------------------------------- ### Decrypting Data Example Source: https://docs.voltbz.net/docs/crypt/decrypt Demonstrates the encryption and decryption workflow using the CBC mode. ```lua local key = crypt.generatekey() local original = "Hello, World!" -- Encrypt and decrypt local encrypted, iv = crypt.encrypt(original, key, nil, "CBC") local decrypted = crypt.decrypt(encrypted, key, iv, "CBC") print(decrypted) -- "Hello, World!" ``` -------------------------------- ### Clearing the Console Example Source: https://docs.voltbz.net/docs/console/rconsoleclear Demonstrates printing text to the console, waiting, and then clearing the output. ```lua rconsoleshow() rconsoleprint("This will be cleared\n") rconsoleprint("So will this\n") task.wait(2) rconsoleclear() rconsoleprint("Fresh start!\n") ``` -------------------------------- ### Base64 Round-trip Example Source: https://docs.voltbz.net/docs/encoding/base64decode Demonstrates encoding a string and then decoding it back to verify data integrity. ```lua local original = "This is a test message!" -- Encode then decode local encoded = base64encode(original) local decoded = base64decode(encoded) print(original == decoded) -- true ``` -------------------------------- ### setfpscap Usage Examples Source: https://docs.voltbz.net/docs/miscellaneous/setfpscap Demonstrates how to set specific frame rate limits or remove the cap by passing zero. ```lua -- Cap at 60 FPS setfpscap(60) -- Remove the cap setfpscap(0) -- Cap at 144 FPS setfpscap(144) ``` -------------------------------- ### mouse2press Usage Example Source: https://docs.voltbz.net/docs/input/mouse2press Demonstrates pressing and releasing the right mouse button with a delay. ```lua mouse2press() task.wait(0.5) mouse2release() ``` -------------------------------- ### mousemoveabs Usage Examples Source: https://docs.voltbz.net/docs/input/mousemoveabs Demonstrates moving the cursor to various screen positions, including a click action. ```lua -- Move to top-left corner mousemoveabs(0, 0) -- Move to center of screen (assuming 1920x1080) mousemoveabs(960, 540) -- Move to specific button location mousemoveabs(500, 300) mouse1click() ``` -------------------------------- ### WebSocket:Close Usage Example Source: https://docs.voltbz.net/docs/websocket/close Demonstrates connecting to a server, sending a message, and closing the connection after a delay. ```lua local ws = WebSocket.connect("wss://your-server.example/socket") ws.OnClose:Connect(function() print("Connection closed") end) -- Use the connection ws:Send("Hello!") -- Close after 10 seconds task.wait(10) ws:Close() ``` -------------------------------- ### Toggle console visibility example Source: https://docs.voltbz.net/docs/console/rconsoletoggle Demonstrates showing, hiding, and re-showing the console window using rconsoletoggle. ```lua -- Create console first rconsoleshow() rconsoleprint("Console is visible\n") -- Toggle it off rconsoletoggle() print("Console is now hidden") -- Toggle it back on rconsoletoggle() rconsoleprint("Console is visible again\n") ``` -------------------------------- ### Simulate Dragging Example Source: https://docs.voltbz.net/docs/input/mouse1press Demonstrates simulating a drag operation by pressing the mouse button and moving the cursor. ```lua -- Simulate dragging mouse1press() for i = 1, 100 do mousemoverel(5, 0) task.wait(0.01) end mouse1release() ``` -------------------------------- ### Retrieve and Iterate Script Globals Source: https://docs.voltbz.net/docs/scripts/getsenv Example demonstrating how to retrieve a script's environment and iterate through its global variables. ```lua local scripts = getrunningscripts() if #scripts > 0 then local env = getsenv(scripts[1]) if env then print("Globals in script:") for key, value in pairs(env) do print("-", key, "=", type(value)) end end end ``` -------------------------------- ### isprotohooked Usage Example Source: https://docs.voltbz.net/docs/closures/isprotohooked Demonstrates checking the hook status of a proto before and after applying a hook. ```lua local function container() local function nested() return 1 end return nested end local proto = debug.getproto(container, 1) print(isprotohooked(proto)) -- false hookproto(proto, function() return 2 end) print(isprotohooked(proto)) -- true restoreproto(proto) print(isprotohooked(proto)) -- false ``` -------------------------------- ### getinstancecache Usage Example Source: https://docs.voltbz.net/docs/instances/getinstancecache Iterates through the cached instances and demonstrates the relationship between the cache and the cache library. ```lua local instanceCache = getinstancecache() local count = 0 for key, instance in pairs(instanceCache) do count += 1 print(key, instance) end print("Cached instances:", count) -- This is the same table used by the cache library local folder = Instance.new("Folder") print(cache.iscached(folder)) -- true folder:Destroy() ``` -------------------------------- ### Custom Image Usage Source: https://docs.voltbz.net/docs/filesystem/getcustomasset Example demonstrating how to retrieve a custom asset URL and apply it to an ImageLabel. ```lua -- The file must already exist in Volt's workspace assert(isfile("myimage.png"), "Add myimage.png to the workspace first") -- Get a usable URL local imageUrl = getcustomasset("myimage.png") -- Use it in a GUI local imageLabel = Instance.new("ImageLabel") imageLabel.Size = UDim2.fromOffset(256, 256) imageLabel.Image = imageUrl imageLabel.Parent = gethui() ``` -------------------------------- ### Setup Hooks on New States Source: https://docs.voltbz.net/docs/actors/on_actor_state_created Use Execute to run initialization code immediately after an actor state is created. ```lua on_actor_state_created:Connect(function(actor) local state = getluastate(actor) -- Execute setup code on the new state state:Execute([[ -- This runs before any scripts execute on the actor print("Actor state initialized!") ]]) end) ``` -------------------------------- ### Hold Left Mouse Example Source: https://docs.voltbz.net/docs/input/mouse1press Demonstrates holding the left mouse button for a specified duration. ```lua -- Hold left mouse for 1 second mouse1press() task.wait(1) mouse1release() ``` -------------------------------- ### Usage Example for makereadonly Source: https://docs.voltbz.net/docs/metatable/makereadonly Demonstrates how to make a table read-only and the resulting error when attempting to modify it. ```lua local myTable = {value = 123} makereadonly(myTable) -- This will error myTable.value = 456 -- Cannot modify read-only table ``` -------------------------------- ### Instance Comparison Example Source: https://docs.voltbz.net/docs/instances/compareinstances Demonstrates how compareinstances correctly identifies identical instances compared to standard equality operators. ```lua local folder = Instance.new("Folder") local clone = cloneref(folder) local other = Instance.new("Folder") -- Normal comparison fails for cloneref print(folder == clone) -- false -- compareinstances works correctly print(compareinstances(folder, clone)) -- true print(compareinstances(folder, other)) -- false ``` -------------------------------- ### getfunctionhash Usage Example Source: https://docs.voltbz.net/docs/closures/getfunctionhash Demonstrates hashing two different functions and verifying the resulting SHA-384 hexadecimal strings. ```Luau local function isSha384Hex(hash) return #hash == 96 and hash:match("^[0-9a-fA-F]+$") ~= nil end local function first() return "constant" end local function second() return "different constant" end local firstHash = getfunctionhash(first) local secondHash = getfunctionhash(second) print(isSha384Hex(firstHash)) -- true print(firstHash == secondHash) -- false ``` -------------------------------- ### Bitwise Operation Examples Source: https://docs.voltbz.net/docs/bit Demonstration of common bitwise operations including AND, OR, XOR, shifting, and hexadecimal conversion. ```lua print(bit.band(0xF0, 0xCC)) -- 192 (0xC0) print(bit.bor(0xF0, 0x0F)) -- 255 print(bit.bxor(0xAA, 0xFF)) -- 85 print(bit.lshift(1, 8)) -- 256 print(bit.tohex(255)) -- "ff" ``` -------------------------------- ### Iterate through signal whitelist Source: https://docs.voltbz.net/docs/signals/getsignalwhitelist Example usage demonstrating how to retrieve the whitelist and print the parent class and event name for each entry. ```lua local whitelist = getsignalwhitelist() for i, entry in ipairs(whitelist) do print(string.format("%s.%s", entry.Parent, entry.Event)) end ``` -------------------------------- ### Invalid Hook Example Source: https://docs.voltbz.net/docs/closures/hookproto Shows an example of a rejected hook due to capturing an upvalue. ```Luau local prefix = "Hooked" -- Rejected because the function captures prefix. hookproto(proto, function(value) return `{prefix}: {value}` end) ``` -------------------------------- ### Logging Utility Example Source: https://docs.voltbz.net/docs/filesystem/appendfile A practical implementation of a logging function that appends timestamped messages to a debug file. ```lua local function log(message) local timestamp = os.date("%Y-%m-%d %H:%M:%S") appendfile("debug.log", "[" .. timestamp .. "] " .. message .. "\n") end log("Script started") log("Player joined") log("Event triggered") ``` -------------------------------- ### Basic Usage of listfiles Source: https://docs.voltbz.net/docs/filesystem/listfiles Demonstrates creating a directory structure and listing its contents using listfiles. ```lua -- Create some files and folders makefolder("mydata") writefile("mydata/file1.txt", "Hello") writefile("mydata/file2.txt", "World") makefolder("mydata/subfolder") -- List contents local files = listfiles("mydata") for _, path in ipairs(files) do print(path) end --[[ mydata/file1.txt mydata/file2.txt mydata/subfolder ]] ``` -------------------------------- ### Setup code on new states Source: https://docs.voltbz.net/docs/luastateproxy/execute Utilizes the Execute method within an event connection to initialize new actor states. ```lua on_actor_state_created:Connect(function(actor) local state = getluastate(actor) state:Execute([[ -- Setup code runs before any scripts print("State initialized!") _G.setupComplete = true ]]) end) ``` -------------------------------- ### Perform a POST Request Source: https://docs.voltbz.net/docs/miscellaneous/request An example showing how to send a JSON-encoded body in a POST request using HttpService. ```lua local HttpService = game:GetService("HttpService") local response = request({ Url = "https://httpbin.org/post", Method = "POST", Headers = { ["Content-Type"] = "application/json" }, Body = HttpService:JSONEncode({ username = "player", score = 100 }) }) if response.Success then local data = HttpService:JSONDecode(response.Body) print(data) end ``` -------------------------------- ### DrawingImmediate Usage Example Source: https://docs.voltbz.net/docs/drawing/immediate Example demonstrating how to draw a filled rectangle and text within a paint callback. ```lua local paint = DrawingImmediate.GetPaint(10) paint:Connect(function() DrawingImmediate.FilledRectangle( Vector2.new(24, 24), Vector2.new(180, 42), Color3.fromRGB(20, 20, 24), 0.9, 6 ) DrawingImmediate.Text( Vector2.new(34, 34), DrawingImmediate.Fonts.Monospace, 16, Color3.new(1, 1, 1), 1, "Volt", false ) end) ``` -------------------------------- ### Script Context Example Source: https://docs.voltbz.net/docs/closures/trampoline_call Demonstrates setting a custom script context so that getcallingscript returns the specified instance. ```Luau local fake_script = Instance.new("LocalScript") local function test() print(getcallingscript() == fake_script) -- true end trampoline_call(test, {}, { script = fake_script, }) ``` -------------------------------- ### Check Console Visibility Example Source: https://docs.voltbz.net/docs/console/rconsolehidden Demonstrates checking the console visibility state using rconsolehidden after toggling the console with rconsoleshow and rconsolehide. ```lua rconsoleshow() if not rconsolehidden() then rconsoleprint("Console is visible!\n") end rconsolehide() if rconsolehidden() then print("Console is now hidden") end ``` -------------------------------- ### Get script hash syntax Source: https://docs.voltbz.net/docs/scripts/getscripthash Defines the function signature for getscripthash. ```lua getscripthash(script: CoreScript | LocalScript | ModuleScript | Script) -> string? ``` -------------------------------- ### mousescroll Usage Examples Source: https://docs.voltbz.net/docs/input/mousescroll Demonstrates how to scroll up, scroll down, and perform multiple wheel steps using positive and negative delta values. ```lua -- Scroll up mousescroll(120) -- Scroll down mousescroll(-120) -- Three wheel steps up mousescroll(120 * 3) ``` -------------------------------- ### Create and compare instance references Source: https://docs.voltbz.net/docs/instances/cloneref Demonstrates creating a clone of an instance reference and verifying that while they point to the same object, they are not equal. ```lua local folder = Instance.new("Folder") folder.Name = "Original" local clone = cloneref(folder) -- Both reference the same instance print(folder.Name) -- "Original" print(clone.Name) -- "Original" -- But they compare as different print(folder == clone) -- false -- Changes through one affect the other clone.Name = "Renamed" print(folder.Name) -- "Renamed" ``` -------------------------------- ### gethwid Usage Example Source: https://docs.voltbz.net/docs/miscellaneous/gethwid Retrieves and prints the current user's opaque identifier. ```lua local identifier = gethwid() print("Volt identifier:", identifier) ``` -------------------------------- ### getthreadidentity Usage Example Source: https://docs.voltbz.net/docs/reflection/getthreadidentity Retrieves and prints the current thread's identity level. ```lua local identity = getthreadidentity() print("Current identity:", identity) ``` -------------------------------- ### identifyexecutor Usage Example Source: https://docs.voltbz.net/docs/miscellaneous/identifyexecutor Captures the returned name and version strings and prints them to the console. ```lua local name, version = identifyexecutor() print("Name:", name) print("Version:", version) ``` -------------------------------- ### Basic Channel Usage Source: https://docs.voltbz.net/docs/actors/create_comm_channel Demonstrates creating a channel, setting up a listener, and firing a message from an actor. ```lua local id, channel = create_comm_channel() -- Listen for messages channel.Event:Connect(function(message) print("Received:", message) end) local actor = assert(getactors()[1], "No active actor state") run_on_actor(actor, [[ local channelId = ... local channel = get_comm_channel(channelId) channel:Fire("Hello from actor!") -- get_comm_channel returns a BindableEvent ]], id) ``` -------------------------------- ### Basic isfolder Usage Source: https://docs.voltbz.net/docs/filesystem/isfolder Demonstrates checking various paths to determine if they are folders, files, or non-existent. ```lua makefolder("myfolder") writefile("myfile.txt", "Hello") print(isfolder("myfolder")) -- true print(isfolder("myfile.txt")) -- false (it's a file) print(isfolder("nonexistent")) -- false (doesn't exist) ``` -------------------------------- ### Using ProtoProxy Source: https://docs.voltbz.net/docs/debug/protoproxy Demonstrates retrieving a ProtoProxy from a function and verifying its type and hash. Note that calling the proxy does not execute the underlying function. ```lua local function outer() local function inner() return "value" end return inner end local proxy = debug.getproto(outer, 1) print(typeof(proxy)) -- ProtoProxy print(proxy.CodeHash) print(proxy()) -- nil; the nested function is not executed ``` -------------------------------- ### Load and use a module file Source: https://docs.voltbz.net/docs/filesystem/loadfile Shows how to load a file that returns a table, effectively using it as a module. ```Luau -- Create a module file writefile("utils.lua", [[ local Utils = {} function Utils.greet(name) return "Hello, " .. name .. "!" end function Utils.add(a, b) return a + b end return Utils ]]) -- Load and use the module local Utils = loadfile("utils.lua")() print(Utils.greet("World")) -- "Hello, World!" print(Utils.add(2, 3)) -- 5 ``` -------------------------------- ### Basic Event Usage Source: https://docs.voltbz.net/docs/luastateproxy/event Demonstrates connecting to an event listener and firing a message within a single state. ```lua local state = getluastate() -- Listen for events state.Event:Connect(function(message) print("Received:", message) end) -- Fire an event state.Event:Fire("Hello from this state!") ``` -------------------------------- ### isfunctionhooked Usage Example Source: https://docs.voltbz.net/docs/closures/isfunctionhooked Demonstrates checking the hook status of a function before and after applying a hook. ```lua local function myFunc() return "original" end print(isfunctionhooked(myFunc)) -- false hookfunction(myFunc, function() return "hooked" end) print(isfunctionhooked(myFunc)) -- true ``` -------------------------------- ### isparallel Usage Example Source: https://docs.voltbz.net/docs/actors/isparallel Demonstrates conditional logic based on the parallel execution state. ```lua if isparallel() then print("Running in parallel!") -- Safe to do parallel-safe operations else print("Running on main thread") end ``` -------------------------------- ### get_current_actor Usage Example Source: https://docs.voltbz.net/docs/actors/get_current_actor Demonstrates how to check if code is running within an Actor context. ```Luau local actor = get_current_actor() if actor then print("Running in Actor:", actor:GetFullName()) else print("Running in the main game state") end ``` -------------------------------- ### Get FPS Cap Syntax Source: https://docs.voltbz.net/docs/miscellaneous/getfpscap The function signature for retrieving the current FPS cap. ```lua getfpscap() -> number ``` -------------------------------- ### Get State for Script Source: https://docs.voltbz.net/docs/actors/getluastate Retrieves the Lua state associated with a specific script instance. ```lua -- Get state for a specific script local script = workspace.SomeScript local scriptState = getluastate(script) print("Script state ID:", scriptState.Id) ``` -------------------------------- ### WebSocket.connect Syntax Source: https://docs.voltbz.net/docs/websocket/connect The basic syntax for initiating a WebSocket connection. ```lua WebSocket.connect(url: string) -> WebSocket ``` -------------------------------- ### Writing to Subfolders Source: https://docs.voltbz.net/docs/filesystem/writefile Demonstrates automatic parent folder creation and explicit folder creation using makefolder. ```lua -- Parent folders are created automatically writefile("data/saves/slot1.txt", "Save data here") -- Or create them explicitly makefolder("logs") writefile("logs/session.log", "Session started") ``` -------------------------------- ### Spoofing Method Calls Source: https://docs.voltbz.net/docs/metatable/setnamecallmethod Example of using setnamecallmethod to intercept and redirect 'FireServer' calls for debugging purposes. ```lua local oldNamecall oldNamecall = hookmetamethod(game, "__namecall", newcclosure(function(self, ...) local method = getnamecallmethod() -- Change FireServer to something else for debugging if method == "FireServer" then print("FireServer intercepted, redirecting...") setnamecallmethod("Fire") end return oldNamecall(self, ...) end)) ``` -------------------------------- ### Basic OnClose Usage Source: https://docs.voltbz.net/docs/websocket/onclose Demonstrates how to connect a callback to the OnClose signal to detect when a connection is terminated. ```lua local ws = WebSocket.connect("wss://your-server.example/socket") ws.OnClose:Connect(function() print("Connection closed") end) -- Later... ws:Close() ``` -------------------------------- ### Simulate Key Release Source: https://docs.voltbz.net/docs/input/keyrelease Demonstrates holding the Shift key for one second before releasing it. ```lua -- Hold shift for 1 second keypress(0x10) -- Shift task.wait(1) keyrelease(0x10) ``` -------------------------------- ### Execute a Luau script file Source: https://docs.voltbz.net/docs/filesystem/dofile Demonstrates creating a file with writefile and executing it using dofile. ```Luau -- Create a script file writefile("greet.lua", [[ print("Hello from greet.lua!") ]]) -- Compile and execute it dofile("greet.lua") ``` ```Luau -- Create and run a script writefile("script.lua", [[ print("Script executed!") for i = 1, 5 do print("Count:", i) end ]]) dofile("script.lua") ``` -------------------------------- ### Using VoltSignal:Once to handle a single event Source: https://docs.voltbz.net/docs/voltsignal/once Demonstrates connecting a function that executes only on the first signal fire and verifying the connection status afterwards. ```lua local signal = VoltSignal.new() local connection = signal:Once(function(value) print("Received:", value) end) signal:Fire("first") -- Received: first signal:Fire("second") -- No output print(connection.Connected) -- false ``` -------------------------------- ### Queueing a script for teleportation Source: https://docs.voltbz.net/docs/miscellaneous/queueonteleport Demonstrates how to queue a string of Luau code to execute upon arrival at a new place. ```Luau -- Queue a script to run after teleporting queueonteleport([[ print("Teleported successfully!") -- Your script code here ]]) -- Teleport the player game:GetService("TeleportService"):Teleport(placeId) ``` -------------------------------- ### Simulate Touch Events Source: https://docs.voltbz.net/docs/instances/firetouchinterest Basic usage of firetouchinterest to simulate starting and ending a touch between two parts. ```lua local firstPart = Instance.new("Part") firstPart.Parent = workspace local targetPart = Instance.new("Part") targetPart.Parent = workspace -- Simulate touch start firetouchinterest(firstPart, targetPart, 0) -- Simulate touch end firetouchinterest(firstPart, targetPart, 1) firstPart:Destroy() targetPart:Destroy() ``` -------------------------------- ### Initialize LuaStateProxy Source: https://docs.voltbz.net/docs/luastateproxy/new Basic usage to retrieve the current state and access its properties. ```lua -- Create a proxy for the current state local state = assert(LuaStateProxy.new(), "Current state is unavailable") print("State ID:", state.Id) print("Is Actor State:", state.IsActorState) ``` -------------------------------- ### Usage examples for getscriptfromthread Source: https://docs.voltbz.net/docs/scripts/getscriptfromthread Demonstrates retrieving the current script from a running coroutine and identifying the source script of a connection. ```Lua local script = getscriptfromthread(coroutine.running()) if script then print("Current script:", script:GetFullName()) end -- Check what script a connection is from local connection connection = game:GetService("RunService").Heartbeat:Connect(function() local thread = coroutine.running() local scriptSource = getscriptfromthread(thread) if scriptSource then print("Heartbeat from:", scriptSource.Name) end connection:Disconnect() end) ``` -------------------------------- ### Create and use a VoltSignal instance Source: https://docs.voltbz.net/docs/voltsignal/new Initializes a new signal, connects a handler function, and triggers the signal with arguments. ```lua -- Create a new signal local onPlayerDamaged = VoltSignal.new() -- Connect a handler onPlayerDamaged:Connect(function(player, damage) print(player.Name .. " took " .. damage .. " damage!") end) -- Fire the signal onPlayerDamaged:Fire(game.Players.LocalPlayer, 50) ``` -------------------------------- ### rconsoleshow() Source: https://docs.voltbz.net/docs/console/rconsoleshow Creates a new console window if one does not exist and displays it to the user. ```APIDOC ## rconsoleshow() ### Description Creates a new console window if one doesn't exist, and shows it. The console can be used to display output and receive user input. ### Syntax `rconsoleshow() -> ()` ### Aliases - rconsolecreate - consolecreate ### Returns - None ### Example ```lua -- Create and show the console rconsoleshow() ``` ``` -------------------------------- ### getscriptthread Usage Example Source: https://docs.voltbz.net/docs/scripts/getscriptthread Retrieves the thread of the first running script and checks its status and reverse lookup validity. ```lua local runningScript = getrunningscripts()[1] local thread = runningScript and getscriptthread(runningScript) if thread then print(coroutine.status(thread)) print(getscriptfromthread(thread) == runningScript) -- true else warn("No running script thread was available") end ``` -------------------------------- ### Redirecting Method Calls Source: https://docs.voltbz.net/docs/metatable/setnamecallmethod Example of using setnamecallmethod to redirect a 'Kick' call to 'GetFullName' within a __namecall hook. ```lua local oldNamecall oldNamecall = hookmetamethod(game, "__namecall", newcclosure(function(self, ...) local method = getnamecallmethod() -- Redirect Kick to a harmless method if method == "Kick" then setnamecallmethod("GetFullName") return oldNamecall(self, ...) end return oldNamecall(self, ...) end)) ``` -------------------------------- ### Basic File Reading Source: https://docs.voltbz.net/docs/filesystem/readfile Demonstrates writing a string to a file and reading it back. ```Luau -- Write and then read a file writefile("message.txt", "Hello, World!") local content = readfile("message.txt") print(content) -- "Hello, World!" ``` -------------------------------- ### Using gethui to hide a ScreenGui Source: https://docs.voltbz.net/docs/instances/gethui Demonstrates creating a ScreenGui and parenting it to the hidden UI container returned by gethui. ```lua local gui = Instance.new("ScreenGui") gui.Name = "MyHiddenGui" gui.Parent = gethui() local frame = Instance.new("Frame") frame.Size = UDim2.new(0, 200, 0, 100) frame.Position = UDim2.new(0.5, -100, 0.5, -50) frame.Parent = gui ``` -------------------------------- ### Parent Thread Context Example Source: https://docs.voltbz.net/docs/closures/trampoline_call Shows how to set a specific parent thread for the execution context, affecting coroutine.running(). ```Luau local fake_thread = coroutine.create(function(...) end) local function test() print(coroutine.running() == fake_thread) -- true end trampoline_call(test, {}, { thread = fake_thread, }) ``` -------------------------------- ### Custom Call Stack Example Source: https://docs.voltbz.net/docs/closures/trampoline_call Demonstrates how to inject a fake caller frame into the stack trace using trampoline_call. ```Luau local function test() print(debug.info(1, "nl")) -- test, 2 print(debug.info(2, "nl")) -- fake_caller, 10 end local function fake_caller() end trampoline_call( test, { { func = fake_caller, currentline = 10, }, }, {} ) ``` -------------------------------- ### Basic rconsoleinput Usage Source: https://docs.voltbz.net/docs/console/rconsoleinput Demonstrates capturing user input and displaying a greeting in the console. ```lua rconsoleshow() rconsoleprint("What is your name? ") local name = rconsoleinput() rconsoleprint("Hello, " .. name .. "!\n") ``` -------------------------------- ### Simulate ProximityPrompt activation Source: https://docs.voltbz.net/docs/instances/fireproximityprompt Demonstrates how to create a ProximityPrompt and trigger it immediately using fireproximityprompt. ```lua local part = Instance.new("Part") part.Parent = workspace local prompt = Instance.new("ProximityPrompt") prompt.Parent = part fireproximityprompt(prompt) part:Destroy() ``` -------------------------------- ### isexecutorclosure Usage Example Source: https://docs.voltbz.net/docs/closures/isexecutorclosure Demonstrates how isexecutorclosure identifies Volt-provided functions and script-defined functions versus game-native functions. ```lua -- Volt functions return true print(isexecutorclosure(loadstring)) -- true print(isexecutorclosure(hookfunction)) -- true -- Your script functions return true local function myFunc() return "hello" end print(isexecutorclosure(myFunc)) -- true -- Game functions return false print(isexecutorclosure(print)) -- false print(isexecutorclosure(game.GetService)) -- false ``` -------------------------------- ### Retrieve and Iterate Actors Source: https://docs.voltbz.net/docs/actors/getactors Example showing how to fetch the list of active actors and iterate through them to print their full names. ```lua local actors = getactors() print("Total actors:", #actors) for i, actor in ipairs(actors) do print(i, actor:GetFullName()) end ``` -------------------------------- ### Simulate Key Press and Release Source: https://docs.voltbz.net/docs/input/keypress Demonstrates pressing the W key, waiting, and then releasing it. Always ensure keys are released after being pressed. ```lua -- Press and release the W key keypress(0x57) task.wait(0.5) keyrelease(0x57) ``` -------------------------------- ### Identify Calling Script in Print Hook Source: https://docs.voltbz.net/docs/scripts/getcallingscript Example of overriding the print function to log the name of the script that initiated the call. ```lua local oldPrint = print print = function(...) local caller = getcallingscript() if caller then oldPrint("[" .. caller.Name .. "]", ...) else oldPrint("[Unknown]", ...) end end -- When a game script calls print, it shows which script ``` -------------------------------- ### Invalidating an Instance Example Source: https://docs.voltbz.net/docs/cache/invalidate Demonstrates removing an instance from the cache and verifying that subsequent lookups may return a different reference. ```lua local folder = Instance.new("Folder") folder.Name = "CacheInvalidateExample" folder.Parent = workspace local firstReference = folder -- Invalidate the cache cache.invalidate(firstReference) -- Looking up the same instance again may return a new reference local secondReference = workspace:FindFirstChild("CacheInvalidateExample") print(rawequal(firstReference, secondReference)) -- false print(compareinstances(firstReference, secondReference)) -- true firstReference:Destroy() ``` -------------------------------- ### Encrypting Data with a Custom IV Source: https://docs.voltbz.net/docs/crypt/encrypt Shows how to provide a manually generated IV for encryption and decryption processes. ```lua local key = crypt.generatekey() local iv = crypt.generatebytes(16) local data = "Secret message" local encrypted = crypt.encrypt(data, key, iv, "CBC") local decrypted = crypt.decrypt(encrypted, key, iv, "CBC") ``` -------------------------------- ### Get and Toggle FPS Cap Source: https://docs.voltbz.net/docs/miscellaneous/getfpscap Retrieves the current FPS cap and toggles it between 60 and 0 if it is currently set to 0. ```lua local currentCap = getfpscap() print("Current FPS cap:", currentCap) if currentCap == 0 then setfpscap(60) else setfpscap(0) end ``` -------------------------------- ### Modifying Script Variables Source: https://docs.voltbz.net/docs/scripts/getsenv Example showing how to modify global variables and invoke functions within a target script's environment. ```lua local targetScript = getrunningscripts()[1] local env = targetScript and getsenv(targetScript) if targetScript and env then -- Modify a variable env.SomeFlag = true -- Call a function from the script if env.SomeFunction then env.SomeFunction() end else warn("No running script environment was available") end ``` -------------------------------- ### Compress and Decompress Data with LZ4 Source: https://docs.voltbz.net/docs/encoding/lz4compress Demonstrates the basic workflow of compressing a string and verifying the result by decompressing it back to the original size. ```lua local data = string.rep("Hello, World! ", 1000) print("Original size:", #data) -- 14000 local compressed = lz4compress(data) print("Compressed size:", #compressed) -- Much smaller local decompressed = lz4decompress(compressed, #data) print(data == decompressed) -- true ```