Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

1 comment

0

Thanks worked great

This discussion is preserved as it was. New answers, comments, and votes are closed.