尝试索引本地pID:数值

如何编写一个脚本来不断检查值的变化,如果值发生变化则切换GUI的开关。 我的代码没有报错,只是当值发生变化时什么都不会发生。

pID=script.Parent.prgrmID.Value
icnID=script.Parent.prgrmID.icnID.Value
if(pID==0 and icnID==0)then
    script.Parent.Visible=false
elseif(pID>0 and icnID>0)then
    script.Parent.Visible=true
elseif(pID>0 and icnID==0)then
print("ICON NOT FOUND")
script.Parent.prgrmIcon.Image="http://www.roblox.com/asset/?id=413746335"
end

script.Parent.prgrmID.Changed:connect(function()
if(pID==0 and icnID==0)then
    script.Parent.Visible=false
elseif(pID>0 and icnID>0)then
    script.Parent.Visible=true
elseif(pID>0 and icnID==0)then
print("ICON NOT FOUND")
script.Parent.prgrmIcon.Image="http://www.roblox.com/asset/?id=413746335"
end
    end)

它没有报错或任何东西。

点赞