function change()
print(555)
end
script.Parent.Parent.Parent.HatSelectedValue.Changed:Connect(change)
The HatSelectedValue is an IntValue, if I try targeting the HatSelectedValue.Value I get an error. What can I do to fix this?
function change()
print(555)
end
script.Parent.Parent.Parent.HatSelectedValue.Changed:Connect(change)
The HatSelectedValue is an IntValue, if I try targeting the HatSelectedValue.Value I get an error. What can I do to fix this?
You can check that the intvalue's value is changed using the :GetPropertyChangedSignal() function
Also, you can add the function connection in the same line as it definition
Using "WaitForChild" will wait until the child exists, you can also use this to see if the ancestry of the intvalue is correct since it will warn an infinite yield if not.
Revised Server / Local Script
local val = script.Parent.Parent.Parent:WaitForChild("HatSelectedValue")
val:GetPropertyChangedSignal("Value"):Connect(function()
print(val.Value)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
That's a lot of parents. Can you show us a picture of where the script is stored? You may not be accessing it correctly.
If you get an error include it!! we do not know what the error is so we cannot help you. Follow https://scriptinghelpers.org/help/how-post-good-questions-answers when posting a question.