How can I make it where I can equip only one thing

Im trying to make an equipping system, its going pretty well but i came across a problem, I am able to equip more than one thing, I want to make where you are only able to equip one thing.

code



local player = game.Players.LocalPlayer
local equipped = false


for index, value in pairs(script.Parent.TrailFolderButtons:GetChildren()) do
	if value:IsA("TextButton") and player.leaderstats.Coins.Value >= value.Price.Value then
		value.MouseButton1Click:Connect(function()
			if value.Text == "Equipped" then
				value.Text = "Equip"
				equipped = false
			else
				value.Text = "Equipped"
				equipped = true
			end
		end)
	end
end

I would Recommend using a table to keep track of what you have, you can add an Item into it, and check if the number of items is less than 0 in order to give you the item, tou can also remove the item, and swap it with the new item

are you saying to create a number value and then apply it into my code, the main goal is to make a trail system, im just mainly focusing on the equipment aspects of it

alright so i did some modifying and made it work

local repstorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer
local equipped = nil

for index, value in pairs(script.Parent.TrailFolderButtons:GetChildren()) do
	if value:IsA("TextButton") and player.leaderstats.Coins.Value >= value.Price.Value then
		value.MouseButton1Click:Connect(function()
			if equipped == value then
				-- If this button is already equipped, unequip it
				value.Text = "Equip"
				equipped = nil
			else
				-- If another button is already equipped, unequip it
				if equipped then
					equipped.Text = "Equip"
				end
				-- Equip this button
				value.Text = "Equipped"
				equipped = value
			end
		end)
	end
end