:GetPropertyChangedSignal is not working

I’m working on a text bar at the bottom of your screen that will read out what is happening in game. However, it is not showing any text at all on the TextLabel.

The text comes from a StringValue in ReplicatedStorage and I’m updating the text using :GetPropertyChangedSignal. However, it is not working although this exact same format is used in another script and it works!

Here is the local script:

local ReplicatedStorage = game.ReplicatedStorage
local TextBarText = ReplicatedStorage.Values:WaitForChild("TextBarText")
local TextBar = script.Parent

TextBarText:GetPropertyChangedSignal("Value"):Connect(function()
	local v = TextBarText.Value
	TextBar.Text = v
end)

Here is the server script (the portion used to show the text):

Players.PlayerAdded:Connect(function()
	pVal = pVal + 1
	print(pVal)
	
	if pVal < 2 then
		TextBarText.Value = ((2 - pVal) .. " more players needed to begin!")
	end	
end)

Players.PlayerRemoving:Connect(function()
	pVal = pVal - 1
	print(pVal)
end)

Can anyone tell what’s up?

1 Like

Sadly still does not work. Thank you for the help though, didn’t know I could do it.

Where is the LocalScript?

The TextBar in the ScreenGui.

30 chars

Did you try printing the string value’s value?
If so, it could be because “pVal” is NOT lower than two nor is it higher, change it to <= 2.
Lastly, It could be because the text was already changed before the connection was made so you do :
TextBar.Text = TextBarText.Value

before putting the connection.

1 Like

Thanks for the reply!

I’m going to test out your second thought. I’ll get back to you when I finish.

Hello! I just tested out your idea and yes, the StringValue is updating. However it is not showing on the TextBar.

It’s not GetPropertyChangedSignal since that just returns an RBXScriptSignal. It’s your code.

ValueObjects have a specialised version of Changed since their properties are limited typically to only a Name and a Value. Changed will fire as in when the value changes and the new value will be passed as a parameter. You only need Changed here.

-- GetService is the canonical way to get a service.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Use WaitForChild on top-level children.
local TextBarText = ReplicatedStorage:WaitForChild("Values").TextBarText
local TextBar = script.Parent

-- Set up initial state
TextBar.Text = TextBarText.Value

-- Update TextBar when ValueObject value changes
TextBarText.Changed:Connect(function (feed)
    TextBar.Text = feed
end)

ValueObject values do replicate client → server so try to set up debugging. If you are doing a Studio play session, you will default to the client environment so you need to change to the server environment if you want to change the value and test if the client writes that change to their Gui.

2 Likes

You should use .Changed for the local script
And instead making a value for the player amount you can just do

pVal = #game.Players:GetPlayers()