Multiple GetPropertyChangedSignal?

How would I make a Multiple GetPropertyChangedSignal because I want something to happend when one of 3 values changes can someone help me or tell if its even possible?

I would use .Changed for this, here are some examples if you’re having trouble!

local neededProperties = {"name", "value", "position"}
Instance.Changed:Connect(function(property)
  if table.find(neededProperties, property) then
        -- What should happen if we find the required properties
  end
end)

or

Instance.Changed:Connect(function(property)
  if property == 'name' then
    -- what happens when name changes?
  elseif property == 'size' then
    -- what happens if the size changes?
  elseif property == 'value' then
    -- What happens if the value changes?
  end
end)

“Happy Scripting!”

~ Sincerely, Ihaveash0rtname

with instance you mean the table right?

No, I mean things like workspace.Part, or workspace.Map.Building1, etc.

but I mean like values if one of their propperty changes something needs to happend

You can just have 3 functions per object.

To add to this, .Changed acts differently for values. So instances like BoolValue, StringValue, IntValue, etc only fire the .Changed event when the value changes, and instead of passing in the property, the argument is the new value.

Here’s an example that uses multiple GetPropertyChangedSignal connections that works for values as well:

local val = Instance.new("BoolValue")

local properties = {"Name", "Value", "Archivable"}

for _, property in pairs(properties) do
	local new, old = val[property], nil
	val:GetPropertyChangedSignal(property):Connect(function()
		new, old = val[property], new 
		print(property.." changed from "..tostring(old).." to "..tostring(new))
	end)
end

val.Value = true 
val.Name = "foobar"
val.Archivable = false

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.