I don't get why you have some many functions called the same. Try using only one like this:
function isPlayerHQHudVisible(thePlayer, hudComponent)
if (isElement(thePlayer)) then
if (getElementData(thePlayer, hudComponent)) then
return true
else
return false
end
else
return false
end
end
function setPlayerHQHudVisible(thePlayer, hudComponent, state)
if (isElement(thePlayer)) then
setElementData(thePlayer, hudComponent, state)
return true
else
return false
end
end
Then, to call them, you can use this:
setPlayerHQHudVisible(localPlayer, "ammo", true)
--and
isPlayerHQHudVisible(localPlayer, "ammo")