Detect if any of a model's children changed color

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

run code on a specific child of a model, whenever it changes color

  1. What is the issue? Include screenshots / videos if possible!

im not sure how to approach this

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

i tried using Instance.Changed on the model but it doesnt work

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

model.Changed:Connect(function()
	if changedPart.BrickColor == BrickColor.new("Tawny") then
		print("its tawny now!")

	elseif changedPart.BrickColor == BrickColor.new("Shamrock") then
		print("its shamrock now!")
		
	end
end)

try this

local model = --model

for i, v in pairs(model:GetChildren()) do
v.Changed:Connect(function()
if v.BrickColor == BrickColor.new("Tawny") then
print("its tawny now!")
elseif v.BrickColor == BrickColor.new("Shamrock") then
print("its shamrock now!")	
end
end)
end
1 Like

connecting .Changed will only fire when that instance gets a property update, so in this case it will not fire when its children change. The first reply should work. Keep in mind that you can also read what property changed by doing the following

part.Changed:Connect(function(ChangedProperty)

end)

or

function onChange(ChangedProperty)

end

part.Changed:Connect(onChange)

.Changed only works for boolvalue, intvalue, etc.
It never works for model property.
So you can try this,

for _,v in pairs(urModel:GetChildren()) do
v:GetPropertyChangedSignal("your property value"):Connect(function()
-- your codes
end)
end

no? .Changed works for every instance in the game. Just how :GetPropertyChangedSignal works for every instance

I bet you’re not that experienced scripter.
https://devforum.roblox.com/t/can-valuechanged-fire-with-nil-even-if-the-value-isnt-set-to-nil/571262/2?u=notskilled_guy

I use .Changed for almost every one of my scripts, have you ever used .Changed? It fires whenever a property of connected instance is changed. Consider reading the developer documentations before claiming things. Also notice how the author marked the first reply as a solution? almost as if it worked because .Changed works for every instance

if you read the actual article you sent what they’re saying is ValueBase instances do not have the same .Change as the other instances in the game. But the other instances do still have a functional .Changed that fires when any property is changed, including hidden ones.

Bruh

No changed event

  • ur code not working at all

image
image

Next step is to learn how to read the documentations. As you can see if you read the documentations you sent, you can clearly see that .Changed is infact an inherited event

Every signle instance has .Changed

image
as you can see, .Changed does not print nil, it prints the signal

compared to stuff that doesn’t have .Changed (not instances)
image
image

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