Ok, so I'm making a tycoon kit and I have a dependency thing so buttons don't appear until all the requirements are met. All the button's parents get set to nil to start with and this is my script for checking the dependencies for each button:
function checkDependancies()
for i,v in pairs(buttonsData) do
local Amount = true
local Speed = true
local Objects = true
print(" "..v[2].Name)
if v["Dependant"] ~= nil then
if v.Dependant["Income"] ~= nil then
if v.Dependant.Income["Amount"] ~= nil then
if script.Parent.IncomeAmount < v.Dependant.Income.Amount then
Amount = false
print("IncomeAmount was less than the required") -- When this is printed the Amount variable still appears to be false!
else
print("IncomeAmount was more than the required")
end
else
print("Amount not found")
end
if v.Dependant.Income["Speed"] ~= nil then
if script.Parent.IncomeSpeed > v.Dependant.Income.Speed then
Speed = false
print("IncomeSpeed was more than the required") -- When this is printed the Speed variable still appears to be false!
else
print("IncomeSpeed was less than the required")
end
else
print("Speed not found")
end
else
print("Income not found")
end
if v.Dependant["Objects"] ~= nil then
for i1,v1 in pairs(v.Dependant.Objects) do
if purchasedObjects:FindFirstChild(v1) == nil then
Objects = false
print(v1.Name.." not found") -- When this is printed the Objects variable still appears to be false!
break
else
print(v1.Name.." found")
end
end
else
print("Objects not found")
end
else
print("Depentant not found")
end
print(Amount)
print(Speed)
print(Objects)
if Amount == true and Speed == true and Objects == true then
v[1].Parent = v[2]
else
v[1].Parent = nil
end
end
end
This doesn't return what I want it to, I put the prints in there to see what happens. It doesn't give any errors but the output is odd, even when the print that's next to setting the variable to false prints, the variable still appears to be true. I'm not sure why this is, here's my output:
Owner Door - 500
Income not found
Objects not found
true
true
true
Increase Income Speed (-1) - 100
Depentant not found
true
true
true
Increase Income Speed (-1) - 300
Income not found
Objects not found
true
true
true
Increase Income Amount (+10) - 100
Depentant not found
true
true
true
Increase Income Amount (+10) - 300
Income not found
Objects not found
true
true
true
Upgrade Walls - 200
Income not found
Objects not found
true
true
true
Build Walls - 100
Depentant not found
true
true
true
