Incrementing position on new GUIs

Hello developers,
Having recently gotten my posting privileges, I’d like to ask you about how you would increment the position of a newly-minted GUI

When I say this, I mean that I am generating new GUIs for every new item that comes into my inventory, like this:

robloxapp-20200515-2040274.wmv (872.6 KB)

Here is the code that I am using to generate a new GUI

local inventory = script.Parent
local localplayer = game.Players.LocalPlayer
local inventoryUI = script.Parent.ScrollingFrame

local replicatedstorage = game:GetService("ReplicatedStorage")
local remotevent = replicatedstorage:WaitForChild("ItemToInventory")

local function UpdateInv(item)
	print(inventoryUI:FindFirstChild(item))
	if inventoryUI:FindFirstChild(item) == nil
	then
		local panel = Instance.new("TextLabel", inventory.ScrollingFrame)
		panel.Name = tostring(item)
		panel.Size = UDim2.new(0, 200 ,0 , 25)
		panel.Text = tostring(item)
		local amount = Instance.new("TextLabel", panel)
		amount.Name = "Amount"
		amount.Size = UDim2.new(0, 30, 0, 25)
		amount.Text = tostring(1)
		print("Player: ", localplayer, " has put ", item, "in their cart")
	else
--		inventoryUI.item.amount.Text = inventoryUI.item.ammount.Text + 1
		inventoryUI:FindFirstChild(item).Amount.Text = inventoryUI:FindFirstChild(item).Amount.Text + 1
	end
end

I’ve barely used these, but maybe a Scrolling Frame and a UIListLayout?

1 Like

Testing it out now, and it seems to be exactly what I was looking for, thank you for the help!

1 Like