Inventory equipping system that relies on player values

How can i make other buttons disabled while one is already clicked/activated because currently, the problem is that you can equip more than 1 stuff at once so I’m trying to find the other buttons that the player did not click and make them disabled, and then when its unequipped all the buttons are enabled.

the script-

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

Hi! I’m sorry if this isn’t what you mean, but this is how I understood the question.

Just a quick thing MouseButton1Click is good for PC/Laptop, but if your going to have tablets/mobile use .Activated it works the same, but it can be used across all platforms (Unsure about Xbox)

After your .MouseButton1Click/.Activated function. You could use a ``` if else`` Example below:

local guiObject = script.Parent.Button
local player = game.Players.LocalPlayer
local value =  1

guiObject.Activated:Connect(function() -- Or guiObject.MouseButton1Click:Connect(function()

if value == 2 then

else 
        -- If value is not the value stated above this code will fire
end)

I hope this helps! Just another quick thing, if you have multiple else make it an elseif (Having a space between words and not having a space changes where the end is and how it functions)

I understand what you mean but there are multiple of the buttons duplicated with the same names thats why i used pairs.

Yes, I’m aware. I just re-read what you said above and the script. Are you trying to stop the buttons from being clickable, if a player clicks another button or only allow input from that button that was selected?

1 Like

Yes, only allow inputs from the button that was selected and when the value is 1, then allow input from all buttons.

Ok. So under when the button gets clicked, you just need a if else to check if the value is 1.