I've been working on an inventory system and when the player places an item down, the value in their inventory is supposed to decrease. However, this doesn't happen, and I'm not sure why.
The code I'm using:
wait(3)
local playername = script.Parent.Parent.PlayerNameTag.Value
local haveitem = game.Players:FindFirstChild(playername).Character.OwnedItems.BlueShrine.Value
if haveitem == 0 then
script.Parent.Parent:Destroy()
end
if haveitem >= 1 then
haveitem = (haveitem - 1)
end
The thing is... the script still knows what the value of BlueShrine is, as it still destroys the model when haveitem is 0. Does anybody know a solution? Am I making an obvious mistake?

2 comments
Can you show us any errors it prints out when you try to do it?
No errors print out.