Dependency not working as intended

Working on a tycoon right now and I have FirstDropperButton, SecondDropperButton, ThirdDropperButton, and Upgrader. I have Dependency stringvalue in SecondDropperButton set to FirstDropper. In ThirdDropperButton I also have a stringvalue to SecondDropperButton but the second, third and upgrader buttons skip right over and spawn in.

f3baec87d5a958badfc761c36dab5c26

And what the StringValues does? whats the code to handle the buttons spawn?

for i, v in pairs(Buttons:GetChildren()) do
	local NewItem = Boughtitems:FindFirstChild(v.Item.Value)
	if NewItem ~= nil then

		items[NewItem.Name] = NewItem:Clone()

		NewItem:Destroy()

	else

		v.ButtonPart.Transparency = 1

		v.ButtonPart.CanCollide = false
		
		v.ButtonPart.BillboardGui.Frame.Visible = false
		
		
	end

	if v:FindFirstChild("Dependency") then

		coroutine.resume(coroutine.create(function()

			v.ButtonPart.Transparency = 1

			v.ButtonPart.CanCollide = false
			
			v.ButtonPart.BillboardGui.Frame.Visible = false

			if Boughtitems:WaitForChild(v.Dependency.Value, 1000000) then

				v.ButtonPart.Transparency = 0

				v.ButtonPart.CanCollide = true
				
				v.ButtonPart.BillboardGui.Frame.Visible = true
			end
		end))
	end

	v.ButtonPart. Touched:Connect(function(Hit)

		if Hit.Parent:FindFirstChild("Humanoid") then

			local player = game.Players:GetPlayerFromCharacter(Hit.Parent)

			if Values.OwnerValue.Value == player then

				if v.ButtonPart.CanCollide == true and v.ButtonPart.Transparency == 0 then

					if player:WaitForChild("leaderstats").Tix.Value >= v.Price.Value then

						player.leaderstats.Tix.Value -= v.Price.Value

						items[v.Item.Value].Parent = Boughtitems

						v:Destroy()
					end
				end
			end
		end
	end)
end

You are iterating a “folder” with all those buttons, if v:FindFirstChild("Dependency") then you turn all buttons transparent etc, and right in the same function you are looking again if any Dependency.Value exist in the button if Boughtitems:WaitForChild(v.Dependency.Value, 1000000) And turning the buttons to transparency 0.
You are double the checking the same thing twice, frist to turn them invisible and then to turn them visible

Do I change one of the transparency?

I think more info is required to know what you should do.
Whats the idea of having stringValues in those buttons with the name of other buttons?
I dont know when you are setting those values, and the purpose of that.

You only mentioned that some buttons spawns and I guess you dont want them to spawn yet. I think you should rework the logic on how your system is working and say more details on whats your goal and whats your approach for it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.