Jump to content
Hotfixx

A quick question about variables.

Recommended Posts

Just got a question about variables:

When you change a variable, does it execute on the client and only the client, or does it broadcast globally and across a full server. For instance, if I was to do "variable = 1" would it equal to one for everybody, or just that player?

 

- Hotfix

Share this post


Link to post
Share on other sites

variable = 1 is a global variable. It would exist across the machine its on. So if you execute variable = 1 it on a client, it will be in all the client side scripts. If you execute it on a server, it will be in all the server scripts.

 

If you want it to be everywhere, you have to make it public using publicVariable "variable" after you change its value.

 

The third type, which you didn't ask about, but it would seem sensible to know about it is a local variable. They always begin with a single underscore, so, _variable.

 

Where they exist is a little more complicated because you have to understand their scope within a script.

 

https://community.bistudio.com/wiki/Locality_in_Multiplayer

 

https://community.bistudio.com/wiki/Variables

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×