Creating a dependency system - how would I do it?

As in line with my last post, I am attempting to create a tycoon from scratch [ meaning no tutorials or tycoon kits ]. Currently I am attempting to create a dependency system that will disable or enable buttons if they depend on purchase [ basically, the player must press a button to get another button to appear ]. My current solution is something like this:

local dependent = part:FindFirstChild("Dependent") -- finds a bool value inside the part

if dependent then end

if debounce == false and cash >= price then
--// rest of code goes here
elseif debounce == false and cash < price then
--// more code goes here
end

Note - this isn’t the exact script I wrote, it’s just the bits I’m having trouble with.

The dependent buttons are invisible and have CanCollide disabled until they are ready to be used. The issue at hand is the fact that the buttons can still be stepped on and activated, despite dependent being set to true. If I do something like this:

if debounce == false and cash>= price and dependent == false then
           part2.Dependent.Value = false
--// more code here
end

It won’t register that the next buttons value is now false, and basically breaks any button beyond the first one.
This is all handled in a script, placed in a model - all changes made are serverside. All variables are defined and carefully checked for. No errors appear in the console.

Forgive me if I used a specific function wrong or made this way more complicated/messy than I should have. I’ve only recently begun scripting and am still learning my way around everything.

After messing around with it for like, an hour or so, I found the solution - the problem wasn’t caused by the system I wrote here. It was caused by the fact that I defined the “Dependent” variable in a “for” loop, and it stuck with the older version of the value rather than the updated one. After re-defining the variable later, outside of the loop, the script continues to works just fine. I absolutely over complicated things, go figure.