So I am trying to make a script that checks if color3 value has changed and applies the color
script.Value:GetPropertyChangedSignal("Color3"):Connect(function()
overhead.TextLabel.TextColor3 = script.Value.Value
overhead.TextLabel2.TextColor3 = script.Value.Value
script.ValueC.Value.Color = script.Value.Value
script.Parent.Torso.Color = script.Value2.Value.Value
script.ValueC.Value.Color = script.Value.Value
end)
But this doesn’t work can someone explain this to me
Although GetPropertyChangedSignal
is ideal for only one property, value objects don’t have many properties apart from parent and its value. Use Changed
event instead.
On another note, the script may not work if the client changes the value while the server is reading it. You want to fire a remote instead if that is the case.
D0RYU
(nici)
June 26, 2021, 2:02pm
3
can you explain to me why you are trying to define ValueC’s color twice?
Thanks, I’ll see what I can do
I think I forgot that it’s already there
script.Value:GetPropertyChangedSignal("Color3"):Connect(function()
If you’re using a Value Object (ValueBase classes) , such as Color3Value, then there’s no such property as Color3
.
Use the Value
property instead.
Like that:
script.Value:GetPropertyChangedSignal("Value"):Connect(function()
I slightly disagree about that.
The .Changed
event fires for every property, such as Name property, or maybe even Parent property.
Isn’t it preferred to be specific with listeners (resources and memory wise)? To make less ‘general’ ones?
Apart that, it is just shorter Syntax, the result in this case will be about the same. Whether .Changed or :GetPropertyChangedSignal
How often do you see Name and Parent change over the course of a game?
Many GUI objects are Destroyed (means the value in them too), especially with things that require “slots” to be added or removed.
But it might not be noticable. I haven’t tested it out, just asking “in theory”.
(Think of an inventory system as an example, where the player can have as many slots (items) as they need, and can also get rid of slots).
I was told sometime ago that value objects don’t change much other than its value. You can just opt for Changed
anyways, this is probably preference.
1 Like