---
title: "setpubvar | open.mp"
description: "Sets a specific public variable in the current script."
canonical: https://omp.itsneufox.com/docs/scripting/functions/setpubvar
language: en
---

# setpubvar

## Description

Sets a specific public variable in the current script.

| Name | Description |
| --- | --- |
| const name\[\] | The public variable's name. |
| value | The value to store in the public variable. |

## Returns

The previous value of the variable.

## Related Functions

-   [getpubvar](https://omp.itsneufox.com/docs/scripting/functions/getpubvar): Gets a specific public variable from the current script.
-   [existpubvar](https://omp.itsneufox.com/docs/scripting/functions/existpubvar): Checks if a specific public variable exists in the current script.
-   [numpubvars](https://omp.itsneufox.com/docs/scripting/functions/numpubvars): Counts how many public variables there are in the script.
