> For the complete documentation index, see [llms.txt](https://risk-scripts.gitbook.io/risk-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://risk-scripts.gitbook.io/risk-scripts/scripts/advanced-metal-detector-script/usage.md).

# Usage

* **Buying or Renting a Detector**
  * An **NPC** (shop) spawns at `Config.Shop.coord`. Players approach and press **E** to open a menu (NUI).
  * They can buy (`Config.Price.buy`) or rent (`Config.Price.rent`) the detector for limited time.
* **Activating the Detector**
  * The script checks if they have the item (`Config.Item = "metal_detector"`).
  * On activation, the player’s movement keys can be restricted (`Config.DisableKeys`).
  * The battery level (from `Upgrades["max_battery"]`) or leftover rent time is considered.
* **Digging**
  * **Shovel required:** If the player attempts to dig but lacks the `shovel` item, an error notifies them.
  * The script spawns a chest object or animates a dig scenario for **`Config.digTime`** (ms).
  * On success, the script randomly picks from `Config.Rewards` (like gold, jewelry, etc.).
  * Each reward item can have a `score` that increases a player’s scoreboard rank.
* **Upgrading**
  * Players can buy upgrades: a bigger battery time, extended radius, or a “radar” feature that more accurately pinpoints items.
  * Some upgrades have multiple levels, each with a **price**; if the player can’t afford it, they get a “no\_money” notification.
* **Tasks & Scoreboard**
  * Achievements revolve around **time** using the detector or number of digs performed.
  * Once a task is complete, the script awards money or items (like pizza, icedtea).
  * The scoreboard ranks players by total `score` from collecting items.
