getscripthash
Gets a hash of a script's bytecode.
Syntax
getscripthash(script: CoreScript | LocalScript | ModuleScript | Script) -> string?Parameters
| Parameter | Type | Description |
|---|---|---|
script | CoreScript, LocalScript, ModuleScript, or client Script | The script |
Returns
| Type | Description |
|---|---|
string? | A lowercase SHA-384 hexadecimal hash, or nil if the script has no bytecode |
Description
getscripthash returns a lowercase SHA-384 hexadecimal hash. It returns nil when bytecode is unavailable.
Example
local module = getloadedmodules()[1]
if module then
local hash = getscripthash(module)
print("Script hash:", hash)
endComparing Scripts
local function sameCode(script1, script2)
local first = getscripthash(script1)
local second = getscripthash(script2)
return first ~= nil and first == second
endTracking Changes
local scriptHashes = {}
local function hasScriptChanged(script)
local currentHash = getscripthash(script)
if not currentHash then
return false
end
local previousHash = scriptHashes[script]
scriptHashes[script] = currentHash
return previousHash ~= nil and previousHash ~= currentHash
endRelated Functions
getscriptbytecode- Get the bytecode being hashedgetfunctionhash- Hash a function