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

How can I make on a GUI go to the next slot when the previous one is taken?

This is kinda a math problem idk

So when creating an inventory system you need the actual storage GUI(Where the player is storing its items). And the players Backpack(The Roblox backpack where tools are stored for players to use). My problem is that when the Backpack stuff is getting transferred over to the GUI storage how do I make it so that the game detects:

Oh there is a tool already using that spot, I guess i'll go to the next one.

Example

As you can see in the example the Tools are going to the next slot because the previous one is already taken. And I also want to do this with mainly math not manual scripting everything bit by bit. It would take a very long time, so how can i do this?

I'm not requesting a script. Just some guidance to how I can do this

1 comment

0

Just detect it the same way that you're remembering what tool is in there. You know what tool is in a slot, ergo you know whether there's a tool in a slot.

1 answer

You can use an if function to check if the slot is taken. In the example you posted, an if function used could be:

for i,v in pairs(frame:GetChildren()) do-- frame being the frame holding all of the slots
	if string.sub(v.Text, 1, 4) == "Slot" then
		-- set it to whatever you need to
	end
end

2 comments

0

Ok cool, but is there a way to tell the game which individual slot to choose? If I'd use "v.Text" then I would be getting all of them.

0

Then use break after the code in the if function.

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