scottb613 285 Posted September 12, 2023 Hi Folks, Probably a basic question - why can't I use "_this" or "this" in a script - I get undefined variable. I have an init field on a vehicle: execVM "initBucks.sqf"; and then if I try to use "this" or "_this" in the intiBucks.sqf - - - as simply as: _veh = _this; I get "_this is undefined". I'm trying to get away from having to name every single vehicle in a mission (and testing for said name) - so I can have a generic script - yet still do work on the individual vehicle calling the script. Thanks. Regards, Scott Share this post Link to post Share on other sites
Harzach 2518 Posted September 12, 2023 execVM "initBucks.sqf"; You are not passing any arguments to your script. It is running in a vacuum. In init: this execVM "initBucks.sqf"; Now, in initbucks.sqf, the object can be referenced as "_this." 1 Share this post Link to post Share on other sites
scottb613 285 Posted September 12, 2023 Hi... Thanks so much - I tried passing an argument - the syntax was wrong. I also thought that "_this" was always known - although the two separate bits of code is probably why it gets lost. 😀 I spent hours trying to work this out before posting. Regards, Scott Share this post Link to post Share on other sites