Skip to main content

SyncVar(LuaBehaviour script, string Name, boolean global = false)

Creates or links the existing synchronized variable. If the synchronized variable does not exist in the multiplayer sessions, it creates and returns a new variable, otherwise it returns the existing variable.

Parameters:

NameTypeDescription
scriptLuaBehaviourThe Script object. Can be accessed from LUA.script.
NamestringName of the variable.
globalbooleanOptional global value makes the synchronized variable accessible in every script if set to true. Otherwise, the synchronized variables scope is limited to the same script in same game object. Like local vs global events.

Usage

---@type LuaBehaviour
local script;

---@type string
local Name;

---@type boolean
local global;


local syncvar = SyncVar(script, Name, global);

Extra Detail

A synchronized variable created with a default value of nil. If a variable exists it’s value is synchronized with session.