Hello there!
So I’m making a tycoon, and I want to make a dependency system.
I tried to make one, but there is just nothing in the console, not even my print() statements.
I’m trying to debug this thing since yesterday and help is really appreciated.
Here is my code (It is in a for _, currentButton in ipairs(Buttons:GetChildren) do
loop, which does work.)
coroutine.wrap(pcall(function()
if currentButton.DependOn:GetChildren() ~= nil then
for _, currentDependency in ipairs(currentButton.DependOn:GetChildren()) do
print(currentDependency)
if currentDependency ~= nil then
if currentButton.DependOn.currentDependency.Value.Bought == true then
currentButton.DependOn.currentDependency:Destroy()
end
end
end
end
if currentButton.DependOn:GetChildren() ~= nil then
print(string.format("%s has %s as dependencies", tostring(currentButton:FindFirstChild("DependOn"):GetChildren())))
currentButton.Button.Transparency = 1
currentButton.Button.CanCollide = false
currentButton.Button.ppr.Enabled = false
elseif currentButton.DependOn:GetChildren() == nil then
print(string.format("%s has no dependencies!", tostring(currentButton)))
currentButton.Button.Transparency = 0
currentButton.Button.CanCollide = true
currentButton.Button.ppr.Enabled = true
end
end)
)
currentButton.Button.ppr.Triggered:Connect(function(player)
local CashValue = player.leaderstats.cash.Value
if Values.Owner.Value == player and bought == false then
if roundNumber(CashValue, 2) >= ItemPrice then
player.leaderstats.cash.Value -= ItemPrice
local boughtDropper = Item:Clone()
boughtDropper.Parent = BoughtItems
currentButton.Button.Transparency = 1
currentButton.Button.CanCollide = false
currentButton.Button.ppr.Enabled = false
bought = true
end
end
end)
end
Here is my workspace: