> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# getscriptbytecode

> Roblox script object の decompressed bytecode string を返します。getscriptbytecode は dumpstring と同じ C++ function に登録されているため、動作は同一です。argument は object である必要があります。共有 bytecode reader は ClassName values ModuleScript、LocalScript、CoreScript、Script を受け入れます。Script では RunContext が Client である必要があります。ClassName がない場合、この function は "Invalid Instance" を発生させます。ClassName が対応する script class ではない場合、"Script expected" を発生させます。値が別の RunContext の Script の場合、"Expected a Script with RunContext set to Client" を発生させます。embedded bytecode reference が無効、または stored bytecode の長さが 8 bytes 以下の場合、この function は nil を返します。それ以外の場合、DecompressBytecode で stored bytecode を展開し、resulting bytes を Luau string として返します。Hash mismatch、too-short compressed data、ZSTD decompression errors はここで発生せず、DecompressBytecode によって error text bytes として返されます。

<div className="real-function-page">
  ```lua theme={null}
  getscriptbytecode(script: userdata): string | nil
  ```

  ## 引数

  <ParamField path={"script"} type={"userdata"} required>
    読み取る Script object。対応する ClassName values は ModuleScript、LocalScript、CoreScript、および RunContext Client の Script です。
  </ParamField>

  ## 戻り値

  <ResponseField name={"bytecode"} type={"string | nil"}>
    Luau string としての decompressed bytecode bytes、DecompressBytecode error text bytes、または利用可能な embedded bytecode がない場合は nil。
  </ResponseField>

  ## 例

  Read decompressed bytecode from a supported Roblox script Instance.

  ```lua theme={null}
  local targetScript

  for _, descendant in ipairs(game:GetDescendants()) do
      if descendant:IsA("LuaSourceContainer") then
          targetScript = descendant
          break
      end
  end

  if targetScript then
      local bytecode = getscriptbytecode(targetScript)
      print(bytecode)
  end
  ```
</div>
