M MY Multiplayer: Wiki
Side
Kind

setElementData

Client

Keeps a piece of data on an element, on this client only.

Also exists on the server, with its own implementation: setElementData

bool setElementData(element element, string key, any value [, bool|string sync = true])

Parameters

NameTypeDescription
elementelementThe element.
keystringThe data's name. Keys over 128 characters are cut, with a warning.
valueanyThe value to keep.
syncbool|stringAccepted as on the server (true, false, "broadcast", "local" or "subscribe"), but ignored. Any other value raises an error.default true

Returns

true if it was kept, false if the element already held that same value.

Fires onClientElementDataChange. Cancelling the event does not undo the change.

Example

setElementData(localPlayer, "hud.visible", false)

if getElementData(localPlayer, "hud.visible") == false then
    outputDebugString("hud hidden")
end
NoteThe data never reaches the server or the other clients, whatever sync says.

See also