Buying script not working

I’m trying to make a script where you select something you want to buy and then you press a buy button to buy it. This is the script where you press the buy button. I made it so that when you select a button it makes a Bool = true. Everything in my script is working except when it checks if the bool’s value is true, it says it’s NOT true, even though the bool IS true. If anyone can find the fix, I will appreciate that very much!

local BuyButton = script.Parent
local player = game.Players.LocalPlayer



BuyButton.MouseButton1Down:Connect(function()
	
	local selected = BuyButton.Parent.Parent:GetDescendants()
	local functions = game:GetService("ReplicatedStorage").Remotes.Upgrades:GetChildren()
	local rfunc = game:GetService("ReplicatedStorage").Remotes.Upgrades.RemoteFunction
	print("Clicekds")
	
	for i,v in pairs(BuyButton.Parent.Parent:GetChildren()) do
		print("i, v")
		if (v:IsA("Frame")) and v.Name ~= "RIghtSide" then
			print("frame")
			for i, vChild in pairs(v:GetChildren()) do
				print("vchsidl")
				if vChild:IsA("TextButton") and vChild.Bool.Value == true then --This is the part that does not work.
					print("textbutons")
					rfunc:InvokeServer(player, vChild.Parent.Name)
					print("Invoking")
					
				end
			end
		end
	end
	
end)

Can’t you just make a debounce variable and check it from there? Kinda like this:

local BuyButton = script.Parent
local player = game.Players.LocalPlayer
local debounce = true


BuyButton.MouseButton1Down:Connect(function()

	local selected = BuyButton.Parent.Parent:GetDescendants()
	local functions = game:GetService("ReplicatedStorage").Remotes.Upgrades:GetChildren()
	local rfunc = game:GetService("ReplicatedStorage").Remotes.Upgrades.RemoteFunction
	print("Clicekds")

	for i,v in pairs(BuyButton.Parent.Parent:GetChildren()) do
		print("i, v")
		if (v:IsA("Frame")) and v.Name ~= "RIghtSide" then
			print("frame")
			for i, vChild in pairs(v:GetChildren()) do
				print("vchsidl")
				if vChild:IsA("TextButton") and debounce then --added debounce
					print("textbutons")
					rfunc:InvokeServer(player, vChild.Parent.Name)
					print("Invoking")
					debounce = false -- change it to false if you want so they can't spam button.
				end
			end
		end
	end
end)

Can you show us the hierarchy of what you’re iterating through? are you sure in the last iteration it loops through and vChild.Bool.Value is actually a ‘BoolValue’ instance? it seems to me vChild could be anything without looking at the hierarchy

This is not how a debounce works, the value needs to be checked that it’s not equal to false, then in the function set to true and at the end of the function set back to it’s default state