Attempt to index number with 'Changed'?

I’m trying to change a textlabel text based off the current numbervalue however it does not seem to change but it does connect to the numbervalue…

local ks = game.Players.LocalPlayer.Miscs.KS.Value -- This is a numbervalue.
KSTEXT.Text = " "..ks

ks.Changed:Connect(function(newVal)

Here are the screenshots:
image
The “0” is suppose to become 2 however it is not.
image

try this:

local ks = game.Players.LocalPlayer.Miscs.KS -- This was the value of the numbervalue
KSTEXT.Text = " "..ks

ks.Changed:Connect(function(newVal)
1 Like

You cannot use .Changed when you’re talking bout the .Value, instead you should do this

local ks = game.Players.LocalPlayer.Miscs.KS
KSTEXT.Text = " "..ks.Value

ks.Changed:Connect(function(newVal)
1 Like

image
I get this error instead.

Do ks.Value.Name maybe

charsss

1 Like

I know this was solved already, but I would like to recommend to use GetPropertyChangedSignal("[THE PROPERTY]") because it would be more efficient, as it directly tracks a specific property, say for this instance, your Value property. Just a recommendation, though.

1 Like

Sorry for bumping this thread but i just wanted to respond to this quote specifically that GetPropertyChangedSignal does not seem to work very well for me due to this error.
:slightly_frowning_face:
image

Are you typing it out correctly?

Yes of course i am.

This text will be blurred

No it wouldn’t. .Changed for instances such as (IntValue, NumberValue, StringValue, etc.) will only fire for the .Value property so GetPropertyChangedSignal is just a bigger hassle to type, is less efficient because the .Changed passes in the new value so you don’t gotta re-access it, and is just unnecessary.

1 Like

I figured that overall, and I do apologize for not including the specifics details, but mostly it’s a better alternative to know of and get used to, especially when considering other instances that you’d need to track a certain property of, and said instance has more than one property that could be changed. Though, thank you for correcting me.

1 Like