M MY Multiplayer: Wiki
Side
Kind

onClientElementDataChange

ClientEvent

Fired when a piece of an element's data changes or is removed. Cancelling the event does not undo the change: this client's data keeps the new value.

addEventHandler("onClientElementDataChange", root, function(string key, any oldValue, any newValue) … end)

Handler parameters

NameTypeDescription
keystringThe data's name.
oldValueanyThe previous value, or nil if the key did not exist.
newValueanyThe new value, or nil if the data was removed.

Source

The element whose data changed.

It also fires when data synced by the server arrives.

Example

addEventHandler("onClientElementDataChange", localPlayer, function(key, oldValue, newValue)
    if key == "money" then
        outputDebugString("money: " .. tostring(oldValue) .. " -> " .. tostring(newValue))
    end
end)

See also