Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

Just do a variable

local oldvalue = stringValue.Value

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

2 comments

0

you forgot one thing, after the event is fired, you should update the oldvalue to the newvalue

0

correct but i just stated an example on how to get the old value before it changed.

This discussion is preserved as it was. New answers, comments, and votes are closed.