Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why do I get the error saying that connect is nil?

Asked by 4 years ago
playerValue.Value.Changed:Connect(function()
    print("----------------")
end)

Very simple script I have a StringValue and whenever its changed I want it to do the function. Instead I get this error and I'm not sure why.

attempt to index nil with 'Connect'

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You're trying to reference an RBXScriptSignal that is custom to the Value property I assume. This does not exist. You can only attached a Changed signal family to an Instance. I suggest using the :GetPropertySignal() twin as it allows us to do exactly what you wish to, hone into the Value property changing. This method allows us to supply an argument of which property we wish to listen to:

playerValue:GetPropertyChangedSignal("Value"):Connect(function()
    print("----------------")
end)

If this works for you, don't forget to accept this answer

0
Thanks worked great minblox0567 2 — 4y
Ad

Answer this question