I don't that is quite what i mean. Let me explain more.
Basically i have an inventory system i just made and what i am trying to add to it is if i click one item in the inventory and then click another, the item in both slots will switch or if one is empty, the item will switch to the empty slot. i made a boolvalue under each slot set to false and each slot is in a table, if one slot is clicked the boolvalue is switched to true but nothing happens, only when another slot is clicked will they switch. So i am trying to check if two random slots in a table is set to true and assign each slot as a variable so i can change all the number values and images between each other.
inventory = {slot1, slot2, slot3, slot4, slot5}
i know how to check if one item in a table like this
for i, v in pairs(inventory) do
if v.value.Value = true then
so how do i check if two items in table is set to true? i wanna be able to do like this say if slot 1 and slot 4 are both true
slot1.value.Value = slot2.value.Value
slot1.item.Value = slot2.item.Value
slot1.ImageLabel.Image = slot2.Imagelabel.Image
1 comment
For swapping variables in arrays, always create a temporary variable to save the swapped data