getscripthash
Gets a hash of a script's bytecode.
Syntax
getscripthash(script: LocalScript | ModuleScript) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
script | LocalScript or ModuleScript | The script |
Returns
| Type | Description |
|---|---|
string | A 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)
endComparing Scripts
local function sameCode(script1, script2)
return getscripthash(script1) == getscripthash(script2)
endTracking Changes
local scriptHashes = {}
local function hasScriptChanged(script)
local currentHash = getscripthash(script)
local previousHash = scriptHashes[script]
scriptHashes[script] = currentHash
return previousHash ~= nil and previousHash ~= currentHash
endRelated Functions
getscriptbytecode- Get the actual bytecodegetfunctionhash- Hash a function