Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to know the property of an object before it has been changed?

Asked by 6 years ago
Edited 6 years ago

For example, I have a .Changed event for the string value:

stringValue.Changed:connect(function(newValue)
    if oldValue == 'EXAMPLE' then
        -- do things
    end
end)

So the event is only fired after the value is changed, and the parameter is also the value after it has changed. So is it possible to know what was the original value before it was changed? I think this needs to do a lot with variables.

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Just do a variable

local oldvalue = stringValue.Value

stringValue.Changed:connect(function(newValue)
    if oldValue == 'EXAMPLE' then
        -- do things
    end
end)

0
you forgot one thing, after the event is fired, you should update the oldvalue to the newvalue Konethorix 197 — 6y
0
correct but i just stated an example on how to get the old value before it changed. casper123123123 357 — 6y
Ad

Answer this question