UI inventory based on values

  1. I’m trying to disable the other buttons if one of them is already equipped
  2. The code
local player = game.Players.LocalPlayer
local val = player.Charactersfolder.equipvalue

local parentstuff = player.PlayerGui.chargui.Inventory

for _,d in pairs(parentstuff:GetDescendants()) do


	if d.Name=='chview' then
		-----
		if player.Charactersfolder.equipvalue.Value == 1 then
			d.Equipbtn.Text = "Equip"
		end
		if player.Charactersfolder.equipvalue.Value == 2 then
			d.Equipbtn.Text = "Unequip"
		end 
		
		-----
		
		d.Equipbtn.MouseButton1Click:Connect(function()
			if player.Charactersfolder.equipvalue.Value == 1 then
				d.Equipbtn.Text = "Unequip"
				wait(0)
				player.Charactersfolder.equipvalue.Value = 2
			end
		end)
		
		
		d.Equipbtn.MouseButton1Click:Connect(function()
			if player.Charactersfolder.equipvalue.Value == 2 then
				d.Equipbtn.Text = "Equip"
				wait(0)
				player.Charactersfolder.equipvalue.Value = 1
			end
		end)
		
	end
end

I can’t find a proper solution so I’m asking for help.

local myButtons = {true, false, false, false, false} -- array containing refrences to all of your buttons equiped states

for i,v in pairs() do
	if v ~= true then --if not equiped then
		--disable the text
	end
end
1 Like