Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i have an inventory that has efficient slots?

When i mean slots, i mean that they slide. I'll provide some images because i am terrible at explaining things.

here's the full selction 1

this is after i click 'light soldier' 2

and this is after i click the almost unreadable one 3

Notice how they all slide to the top?

The only way i would know how to do this is with a ton of ifs.

if not gui.Position == UDim2.new(0,13,0,123) then
	gui2.Position = UDim2.new(0,13,0,123)
end

Above is good enough for like 2 slots, but what if i had 20 or more? Just more if's is all i can think of. Can you give me a little demo of a more efficient way to do this?

4 comments

1

uh what? and if i read this right youll have to resize and reposition based on the number of children under the slot holder

0

It's like this: The player starts with 1 item in their inventory, then they get another one! they get another item in their inventory, show by a gui. Then, they lose Item1! Then item 2 goes to item 1's position. And that's what I'm trying to have happen over tons of Items

0

lol conquerors

0

^ conquerors FTW

1 answer

Use a table

When you click one, you can remove the item from the position that it's at and put it in position 1. Then you can iterate through the table and reposition every single thing based on its new table position. If you use table.remove to remove the item and move it to position 1 then all of the entries will move themselves in the table.

1 comment

0

this doesn't work, can you tell me what I'm doing wrong? http://hastebin.com/uxahuguhet.lua

This discussion is preserved as it was. New answers, comments, and votes are closed.