How to check if any property in an object is changed

Yes, I know GetPropertyOnChangedSignal exists but I want to check if any property is changed, since this only checks 1 property is changed, how to do this?

1 Like

You can use:

local StringValue = script.StringValue

String.Changed:Connect(function()
  -- Your code here
end)
1 Like

But how do I detect which property is changed?

It has an argument of the property here


local part= Instance.new("Part")

part.Changed:Connect(function(p)

print(p)
  -- Your code here
end)

5 Likes

I believe that just only returns the value of the property, I think I’m wrong

No it returns the name of the property that changed

1 Like

ok thx!!!

For a StringValue instance, its “.Changed” event only fires when its Value property changes, the RBXScriptSignal’s parameter represents the new value of that property, i.e;

local stringValue = workspace.StringValue

stringValue.Changed:Connect(function(string)
	print(string)
end)

stringValue.Value = "Hello world!" --Event fires and "Hello world!" is printed.
stringValue.Name = "StringInstance" --Event doesn't fire.

For all other types of instances, their “.Changed” RBXScriptSignal object will fire whenever the value of any of their properties is changed, with the parameter being the name of that property as a string type value, i.e:

local part = workspace.Part

part.Changed:Connect(function(property)
	print(property)
end)

part.Name = "Test" --Event is fired and "Name" is printed.
part.Parent = nil --Event is fired and "Parent" is printed.

i was putting string value as an example. It doesn’t have to be a string value

Well your example would only work if the StringValue’s Value property is changed. The thread’s poster was looking for a way to detect if the value of any of an instances properties is changed.