Script identifies that the value is true when it is not

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")

Phase2 is not printing, why is that happening?

I hope you respond me :+1:

not HasBought is the same thing as if HasBought == nil then.

HasBought exists, which is why it won’t go to phase two.

i wrote this ~= which identifies when is NOT, for example:

if xp.value ~= 100 then

that identifies when xp.value is not 100.

if xp.value == 100 then

that identifies when xp.value is 100

I want to know when the value is false.

You say:

if HasBought ~= nil then

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.

Okay so for HasBrought you are missing the variable .Value,

please correct this to HasBrought.Value

On top of this,

correct if not HasBought then to

if HasBought.Value == nil then