GetPropertyChangedSignal function not working

Hi, I am trying to have the text change if the value changed that is parented to the player, but it’s not working. Here is my code:

player:FindFirstChild("PrimaryColor"):GetPropertyChangedSignal("Value"):Connect(function()
	script.Parent.Text = "Primary Color: " .. player:FindFirstChild("PrimaryColor").Value
end)
1 Like

Try using WaitForChild instead. Also, you are sure you are putting a value object in, correct? Any errors at all in the output?

2 Likes

That didn’t change anything, I did have it set to a value but that’s not changing anything. No errors either.

Does the value ever change? I usually set the text two times, right when the object is added and after it has changed.

It gets set when you join the game, and if you et a different color, it’ll change to that value.

First of all, I’m not sure why you’re using FindFirstChild to get it everytime when you can just use player.PrimaryColor.

Second of all, it’s better to use Changed for ValueObjects instead of GetPropertyChangedSignal.

The code looks like it should work. Maybe the problem is somewhere else in the script? Can you show more of the script?

Are you having any errors in the output?

That’s all that’s in the script except the player variable, which is getting the local player. this script is a local script too.

Hmm oddly it works when I choose another color from the menu, but not when it starts up… odd…

Then your issue is that you’re not applying the initial value. The script is running after it gets changed, so the initial event doesn’t fire. (i hope that made sense sorry)

function UpdatePrimaryColorDisplay(color)
	script.Parent.Text = "Primary Color: " .. color
end

UpdatePrimaryColorDisplay(player.PrimaryColor.Value)
player.PrimaryColor.Changed:Connect(UpdatePrimaryColorDisplay)

The changed event on ValueObjects returns the new value, so we don’t need to grab it manually. GetPropertyChangedSignal does not for performance reasons.

1 Like