As the tittle says the script identifies that the value is true, but it is not, here is the main problem:
local Button = PetsFrame:FindFirstChild(object)
print(Button)
local HasBought = Button:FindFirstChild("HasBought")
print("Phase1")
if HasBought ~= nil then
print("Phase1.5")
if not HasBought then
print("Phase2")
and it jumps into this section of the code, which means HasBought exists.
But then you say:
if not HasBought then
This is contradictory to your first if statement. It is the exact opposite. First you check to see if HasBought exists, and then you check to see if it doesn’t.
Since the first statement just said it exists, and you didn’t destroy HasBought, theres no reason for it to not exist immediately after.