Dependency system does not re-enable buttons

I have a dependency system with my buttons so that if I buy a button another appears.
The only problem is, that if I buy a button the other one doesn’t appear.
It does become disabled, though.

I searched everything and I’m trying to fix this since 2 days and I just can’t seem to do it.

Here’s my code:

-- buy functions --

coroutine.wrap(function()
	for _, currentButton in ipairs(Buttons:GetChildren()) do
		local bought = currentButton.Bought.Value
		for _, currentDependency in currentButton.DependOn:GetChildren() do
			
			if currentDependency.Value.Bought.Value == true then
				currentDependency:Destroy()
			end

			if #currentButton.DependOn:GetChildren() > 0 then
				currentButton.Button.Transparency = 1
				currentButton.Button.CanCollide = false
				currentButton.Button.ppr.Enabled = false

			elseif #currentButton.DependOn:GetChildren() == 0 and not bought then
				currentButton.Button.Transparency = 0
				currentButton.Button.CanCollide = true
				currentButton.Button.ppr.Enabled = true
				
			else
				warn("not a number (maybe checking wrong thing?)")
			end
		end
	end
end)()

Thanks for helping!

Why you doing this

Is that a mistake or is there a boughtValue in something called “Value”?

Oh you put this

local bought = currentButton.Bought.Value

But you can’t store properties in variables, get rid of .Value then when checking do

elseif #currentButton.DependOn:GetChildren() == 0 and not bought.Value then

Hello, and thanks for replying.
Storing properties in variables is possible, I added a print(bought) statement and it printed false
image
However, I still tried changing it but it did not change anything.
EDIT: I checked if the ObjectValue for the dependency got removed if it got bought and turns out it doesn’t because the bought value nevers gets set to true.
Even when manually set to true the button never appears, so I manually deleted the dependency value and it still didn’t work.