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
| Name | Type | Description |
|---|---|---|
| key | string | The data's name. |
| oldValue | any | The previous value, or nil if the key did not exist. |
| newValue | any | The 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)