How to make shop system equip/unequip

I want to make a shop with a equip/unequip system on it, i just can make a shop but not a equip/unequip system

Events:

game.ReplicatedStorage.Buy.OnServerEvent:Connect(function(player, item)
	for _, i in pairs(player.Backpack:GetChildren()) do
		if i.Name == 'Item'..item then return end
	end

	for _, i in pairs(player.Character:GetChildren()) do
		if i.Name == 'Item'..item then return end
	end

	local clone = game.ReplicatedStorage.Items["Item"..item]:Clone()
	clone.Parent = player.Backpack

end)

Item:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.ItemInfo.Item.Value = 1
end)

Buy Script:

script.Parent.MouseButton1Click:Connect(function()
	local item = script.Parent.Parent.Item.Value

	game.ReplicatedStorage.Buy:FireServer(item)
end)

Who can help please!

1 Like

You can make equippedToolValue.

local equippedTool = Instance.new("StringValue",player); equippedWeapon.Name = "EquippedTool"

then change buy script

game.ReplicatedStorage.Buy.OnServerEvent:Connect(function(player, item)
	if not player:FindFIrstChild(item) then
-- buy code here
   else
      if plr.equippedTool.Value == item then
         -- unequip code
      else
       --equip code here
       end
end
end)

dont forget to save this value with datastore
if you have any question feel free to ask

1 Like

okay if you can send me friend request in discord
я тоже умственно отсталый#4224