{"name":"private","operator":null,"title":"private","type":"command","url":"https://community.bistudio.com/wiki/private","revid":377850,"updated":"2026-01-03T11:40:32Z","groups":["Variables"],"status":"ok","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.00"},{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofp","name":"Operation Flashpoint","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Sets a variable to the innermost scope. See also param and params.\n\n> [!WARNING]\n> - private variables **must** start with an underscore:  - see Identifier.\n> - **Always** make your local variables **private** (through private or params) in order to avoid overwriting a local variable of the same name.","syntaxes":[{"syntax":"private variableName","since":null,"effect":null,"exec":null,"params":[{"name":"variableName","type":"String","optional":false,"default":null,"description":"e.g `\"_myVar\"`","types":["String"],"since":null,"text":"variableName: String - e.g `\"_myVar\"`"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"variableName","types":["String"]}},{"syntax":"private variableNameList","since":null,"effect":null,"exec":null,"params":[{"name":"variableNameList","type":"Array of Strings","optional":false,"default":null,"description":"e.g `[\"_target\", \"_damage\"]`","types":["Array","String"],"since":null,"text":"variableNameList: Array of Strings - e.g `[\"_target\", \"_damage\"]`"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"variableNameList","types":["Array","String"]}},{"syntax":"private _identifier = value From Arma 2 v1.00 to Arma 3 v1.52: see local","since":"arma3 1.54","effect":null,"exec":null,"params":[{"name":"_identifier","type":"underscored variable name, for example `_myVar`","optional":false,"default":null,"description":null,"types":["Identifier"],"since":null,"text":"_identifier: underscored variable name, for example `_myVar`"},{"name":"value","type":"Anything: value to assign to the variable","optional":false,"default":null,"description":null,"types":["Anything"],"since":null,"text":"value: Anything: value to assign to the variable"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"_identifier = value From Arma 2 v1.00 to Arma 3 v1.52: see local","types":[]}}],"examples":[{"text":"```sqf\nprivate _varname = \"this is my new variable\"; // since Arma 3 v1.54\n\n// identical, but less performant\nprivate \"_varname\";\n_varname = \"this is my new variable\";\n```","code":["private _varname = \"this is my new variable\"; // since Arma 3 v1.54\n\n// identical, but less performant\nprivate \"_varname\";\n_varname = \"this is my new variable\";"]},{"text":"```sqf\nprivate [\"_varname1\", \"_varname2\"];\n_varname1 = \"variable 1\";\n_varname2 = \"variable 2\";\n```","code":["private [\"_varname1\", \"_varname2\"];\n_varname1 = \"variable 1\";\n_varname2 = \"variable 2\";"]},{"text":"```sqf\n_lol = 123; call { hint str [_lol] }; // [123]\n_lol = 123; call { private \"_lol\"; hint str [_lol] }; // [any]\n```","code":["_lol = 123; call { hint str [_lol] }; // [123]\n_lol = 123; call { private \"_lol\"; hint str [_lol] }; // [any]"]},{"text":"```sqf\n_myvar = 123;\nsystemChat str [_myvar];        // [123]\ncall {\n    systemChat str [_myvar];    // [123]\n    private \"_myvar\";\n    systemChat str [_myvar];    // [any]\n    _myvar = 345;\n    systemChat str [_myvar];    // [345]\n};\nsystemChat str [_myvar];        // [123]\n```","code":["_myvar = 123;\nsystemChat str [_myvar];\t\t// [123]\ncall {\n\tsystemChat str [_myvar];\t// [123]\n\tprivate \"_myvar\";\n\tsystemChat str [_myvar];\t// [any]\n\t_myvar = 345;\n\tsystemChat str [_myvar];\t// [345]\n};\nsystemChat str [_myvar];\t\t// [123]"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["param","params","privateAll"],"notes":[{"user":"Faguss","date":"2010-08-04T13:30:00Z","text":"The higher scope is also the script from which the function has been called.\n\nin **script2.sqf**:\n\n```sqf\n_a = 2;\n```\n\nin **script1.sqf**:\n\n```sqf\n_a = 1;\ncall compile preprocessFileLineNumbers \"script2.sqf\";\nhint format [\"%1\", _a];\n```\n\nGame will display 2.\n\nInserting `private \"_a\"` in the function prevents the change and so number 1 will be displayed on the screen."},{"user":"DreadedEntity","date":"2015-02-25T17:06:00Z","text":"Recursive loops require the use of private. Without it, your variables will be overwritten."},{"user":"654wak654","date":"2018-01-31T10:37:00Z","text":"This command is *similar* to javascript's [let](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let) keyword.\n\n**EDIT:** in the way that it scopes the variable to the innermost scope. Otherwise, let and private can behave differently - Lou Montana (talk)"}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Variables","Introduced with Operation Flashpoint version 1.00","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}