Sorry if it’s not specific enough, didn’t how to describe that.
For example, when I equip an item, and I equip the same item but it’s not the original I equipped earlier, it unequips the old one? Even if I change the currentSelectedItem, it still thinks it’s equipped.
Inventory.Selection.Equip.Activated:Connect(function()
if currentSelectedItem and currentSelectedButton then
print(currentSelectedItem:GetAttribute("Equipped"))
if already==false or currentSelectedItem:GetAttribute("Equipped")==false then
print("f")
already = true
local tool = currentSelectedItem:Clone()
local canEquip = ReplicatedStorage.Functions:WaitForChild("CanEquip"):InvokeServer(plr,tool)
if canEquip==true then
tool.Parent = plr.Backpack
Inventory.Selection.Equip.Text = "UNEQUIP"
currentSelectedButton.TextColor3 = Color3.fromRGB(255, 255, 0)
currentSelectedItem:SetAttribute("Equipped",true)
tool:SetAttribute("Equipped",true)
Inventory.Selection.Equip.Text = "UNEQUIP"
else
local itemType = tool:GetAttribute("Type")
ReplicatedStorage:WaitForChild("False"):Play()
task.spawn(function()
if itemType == "Weapons" then
Inventory.Selection.Equip.Text = "CAN ONLY EQUIP"..weaponLimit.." WEAPONS"
elseif itemType == "Equipment" then
Inventory.Selection.Equip.Text = "CAN ONLY EQUIP"..equipmentLimit.." EQUIPMENT"
elseif itemType == "Accesory" then
Inventory.Selection.Equip.Text = "CAN ONLY EQUIP"..accesoryLimit.." ACCESORIES"
end
task.wait(1.25)
Inventory.Selection.Equip.Text = "EQUIP"
end)
end
elseif currentSelectedItem:GetAttribute("Equipped")==true then
-- print("d",currentSelectedItem:GetAttribute("Equipped"),already)
already = true
Inventory.Selection.Equip.Text = "EQUIP"
currentSelectedButton.TextColor3 = Color3.fromRGB(0, 0, 0)
currentSelectedItem:SetAttribute("Equipped",false)
if char:FindFirstChild(currentSelectedItem.Name) or plr.Backpack:FindFirstChild(currentSelectedItem.Name) then
if char:FindFirstChild(currentSelectedItem.Name) then
char.Backpack:FindFirstChild(currentSelectedItem.Name):Destroy()
end
if plr.Backpack:FindFirstChild(currentSelectedItem.Name) then
plr.Backpack:FindFirstChild(currentSelectedItem.Name):Destroy()
end
end
Inventory.Selection.Equip.Text = "EQUIP"
end
end
end)
-------------------------------------------------------------------------------------------
for i, item in ipairs(plr.InventoryF:GetChildren()) do
local button = Inventory.ScrollingFrame.Template:Clone()
button.Visible = true
button.Text = item.Name
button.Parent = Inventory.ScrollingFrame
button.Activated:Connect(function()
currentSelectedButton = button
currentSelectedItem = item
toggleSelectionInfo(true)
end)
end