Changed metamethod?

Hello!

I was wondering if there were any metamethods to determine when a value was changed? If not, how would I go about doing this?

['new'] = function(wordsToWrite)
		local object = {
			['WordsToWrite'] = wordsToWrite;
			['Stopped'] = false;
			['Adornee'] = nil;
			['Speed'] = 0; -- example here, if I wanted to set a max of 10, how would I go about erroring when it is set and is over 10 or not a number?
			['Play'] = function(self)
				coroutine.wrap(function()
					for i = 1, self.WordsToWrite:len() do
						self.Adornee.Text = self.WordsToWrite:sub(1, i)
						runService.RenderStepped:Wait()
					end
				end)()
			end;
			['Cancel'] = function(self)
				self.Stopped = true
			end;
		}

TIA for any help!

You could use a proxy table with the __newindex metamethod

1 Like