#Button changing to wrong button on pressed action

1 messages · Page 1 of 1 (latest)

visual tiger
#

Hello! I'm having a very minor issue with my button feedback in my shop GUI. I explained this in an earlier post but my game only allows you to have one item equipped at a time and changes all of the other buttons to equip while changing only the pressed one to say unequip. I am adding some feedback to the buttons and this system is working fine and the buttons themselves are working fine too except for one thing, if I unequip the already existing item in my inventory the GUI element changes to say Equip whenever the button is pressed down and goes back to unequip. I am looking to make this button specifically still say Equip if the same one is pressed and it's out of the inventory.

        if purchaseOutcome or playerItemsFolder:FindFirstChild(selectedButton) then
            for _, btn in pairs(purchasedButtonsTable) do --Loops that sets EVERY button to say equip when it's pressed
                btn.Image = "rbxassetid://121775972432240" --Equipped image ID
                btn.HoverImage = "rbxassetid://134252875299549" -- Equipped hover ID
                btn.PressedImage = "rbxassetid://73801134670680" --Equipped pressed ID
                btn.UIStroke.Color = Color3.fromRGB(0, 49, 0)
            end
            if table.find(purchasedButtonsTable, buttonPress) then --Changes the pressed button to say Unequip
                buttonPress.Image = "rbxassetid://135068090045978" --Unequipped image ID
                buttonPress.HoverImage = "rbxassetid://92222183206336" --Unequipped hover ID
                buttonPress.PressedImage = "rbxassetid://73801134670680" --Equpipped pressed ID
                buttonPress.UIStroke.Color = Color3.fromRGB(43, 0, 0)
            end
        end
    end)
end