M MY Multiplayer: Wiki
Side
Kind

onElementDataChange

ServerEventCancellable

Fired when a piece of an element's data changes or is removed. Cancelling the event puts the previous value back (or removes the key if it did not exist), and the change is not sent to the players.

addEventHandler("onElementDataChange", 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.

A client's data never reaches the server, so the change always comes from a server script.

Example

addEventHandler("onElementDataChange", root, function(key, oldValue, newValue)
    if key == "admin" and getElementType(source) == "player" then
        cancelEvent()
    end
end)

See also