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
| 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.
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)