.changed value help

Hiya guys, this could be me being really dumb but .changed doesnt seem to be working.

I am making changes on the server via studio, and in testing it doesnt seem to be picking it up. is it cause the script with the.changed is local?

Player.PlayerStats.Strength.Changed:Connect(function()
	UI.stats.Strength.Text = ("STRENGTH: "..Strength)
end)

How were you able to tell if it wasn’t being picked up? Have you tried placing a print inside the event callback to see if it has been fired?

Anyway, from what I can tell, the problem is that you haven’t created a strength variable in the function parameters.

Player.PlayerStats.Strength.Changed:Connect(function(strength)
	UI.stats.Strength.Text = "STRENGTH: " .. strength
end)

if its an int value, you are checking if the instance “strength” is getting changed, not the value that it stores. try this instead:

Player.PlayerStats.Strength.Value.Changed:Connect(function(strength)
	UI.stats.Strength.Text = "STRENGTH: " .. strength
end)

note: I would recommend using “GetPropertyChangedSignal(“Value”)” instead of using “.Changed”

I tried this, and it just came up with this error:

Players.Lukaa_Playz.PlayerGui.ScreenGui.Frame.StatHandler:39: attempt to index number with 'Changed' 

I think it might have something to do with the function(strength), I would recommend using GetPropertyChangedSignal() instead:

Player.PlayerStats.Strength:GetPropertyChangedSignal("Value"):Connect(function()
	local strength = Player.PlayerStats.Strength.Value
	UI.stats.Strength.Text = "STRENGTH: " .. strength
end)

if for some reason you need to use .Changed, do this:

Player.PlayerStats.Strength.Value.Changed:Connect(function()
	local strength = Player.PlayerStats.Strength.Value
	UI.stats.Strength.Text = "STRENGTH: " .. strength
end)

That seemed to do the trick
forgot GetPropertyChangedSignal() existed.
thanks for the help!

For future readers, the reason this error happened is because the correct way of using .Changed is shown here: