Volt

getscripthash

Gets a hash of a script's bytecode.

Syntax

getscripthash(script: LocalScript | ModuleScript) -> string

Parameters

ParameterTypeDescription
scriptLocalScript or ModuleScriptThe script

Returns

TypeDescription
stringA hash string of the bytecode

Description

getscripthash returns a hash of a script's compiled bytecode. Scripts with identical code will have the same hash.

Example

local scripts = getrunningscripts()
if #scripts > 0 then
    local hash = getscripthash(scripts[1])
    print("Script hash:", hash)
end

Comparing Scripts

local function sameCode(script1, script2)
    return getscripthash(script1) == getscripthash(script2)
end

Tracking Changes

local scriptHashes = {}

local function hasScriptChanged(script)
    local currentHash = getscripthash(script)
    local previousHash = scriptHashes[script]
    
    scriptHashes[script] = currentHash
    
    return previousHash ~= nil and previousHash ~= currentHash
end

On this page