Getting Original Value

How can I get the original value before the change using a .Changed event? The only parameter is the property…

local OriginalValue -- original value

Object.Changed:Connect(function()
        OriginalValue = Object.Value
        --script
end)

Only way u could do that is like this,

1 Like

Isn’t ‘object.value’ the changed value because it is in the .Changed event? (meaning that the property is already changed?)

Here, let me rewrite his code a little more and explain.

local OriginalValue = Object.Value -- original value

Object.Changed:Connect(function(newValue)
  print(OriginalValue, newValue) --Print our old and new
  --Code using old and new
  OriginalValue = newValue --Out with the old, in with the new
end)
1 Like

Yes. when the object changes it value we’re basically updating the variable at the top, if u wanna do something to the older value before u update it again put the script first then update it in this format

local OriginalValue -- original value

Object.Changed:Connect(function()
        --script
        OriginalValue = Object.Value
end)
2 Likes