You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I am working on an inventory system for a game. The way it works is that when a player picks up an item, the item gets added to a table. The index of the item corresponds to the ImageButtons name (first item in the table changes the image of the ImageButton object named “1”). When an item gets dropped it gets removed from the table, the images that were behind the dropped item will move forward and take the empty space infront of them. -
What is the issue? Include screenshots / videos if possible!
The slots 3 and 4 do not seem to change images even though there is another/no item in the table that has the index 3 or 4, every other slot works except those two.
Here is a video of the problem
The red bouncy balls on slot 3 and 4 presist even though they have been removed from the table
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have looked but as far as I have searched, there was no one who had the same issue as me. I reviewed my own code and its working perfectly fine except for the slots 3 and 4
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
This is the code that is responsible for the removal of images
dropItem.OnClientEvent:Connect(function(item)
if item ~= "Gadget" and item ~= "Armor" then
table.remove(invItems, item)
for i, slot in pairs(frame:GetChildren()) do
local num = tonumber(slot.Name)
if not slot:IsA("ImageButton") then return end
if invItems[num] then
for itemName, id in pairs(itemImgs) do
if itemName == invItems[num].Name then
slot.Image = id
end
end
else
print(slot.Name)
slot.Image = "rbxassetid://0"
end
end
else
local slot = frame:FindFirstChild(item)
slot.Image = "rbxassetid://0"
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.