local Slots = 27
local SlotsPerRow = script.Parent.Settings.SlotsPerRow.Value
local GuiSizeX = 950
local GuiSizeZ = 470
local SlotSizeX = 100
local SlotSizeZ = 100
local SpaceBetweenItems = 5
local CurrentSlots = 0
local CurrentPosX = SpaceBetweenItems
local CurrentPosZ = SpaceBetweenItems
local SlotTemplate = script.Parent.Slots.SlotTemplate

function CreateNewSlot()
	
	if CurrentSlots ~= SlotsPerRow then
	
	local NewSlot = SlotTemplate:Clone()
	NewSlot.Parent = script.Parent.Slots
	NewSlot.Size = UDim2.new(0, SlotSizeX, 0, SlotSizeZ)
	NewSlot.Visible = true
	NewSlot.Position = UDim2.new(0, CurrentPosX, 0, CurrentPosZ)
	CurrentPosX = CurrentPosX + SpaceBetweenItems + SlotSizeX
	CurrentSlots = CurrentSlots + 1
	
	else
		
	CurrentSlots = 0
	CurrentPosX = SpaceBetweenItems
	CurrentPosZ = CurrentPosZ + SpaceBetweenItems + SlotSizeZ
	
	end
	
end

wait ()
while true do
	wait (1)
	CreateNewSlot()
end

This script works for a normal frame but how would you do this with a scrolling frame?

(I would like to adapt the scrolling frame to the slots. Are there any tutorials or something similar?)

Fixed!

local Slots = 27
local SlotsPerRow = script.Parent.Settings.SlotsPerRow.Value
local GuiSizeX = 950
local GuiSizeZ = 470
local SlotSizeX = 100
local SlotSizeZ = 100
local SpaceBetweenItems = 5
local CurrentSlots = 0
local CurrentPosX = SpaceBetweenItems
local CurrentPosZ = SpaceBetweenItems
local SlotTemplate = script.Parent.Slots.SlotTemplate
local CanvasSizeZ = 105
local CanvasSizeX = GuiSizeX
local Rows = 1

wait (3)

function CreateNewSlot()
	
	if CurrentSlots ~= SlotsPerRow then
	
	local NewSlot = SlotTemplate:Clone()
	NewSlot.Parent = script.Parent.ScrollingFrame
	NewSlot.Size = UDim2.new(0, SlotSizeX, 0, SlotSizeZ)
	NewSlot.Visible = true
	NewSlot.Position = UDim2.new(0, CurrentPosX, 0, CurrentPosZ)
	CurrentPosX = CurrentPosX + SpaceBetweenItems + SlotSizeX
	CurrentSlots = CurrentSlots + 1
	
	else
		
	print "SOS"
	Rows = Rows + 1
	local Number = ( SlotSizeZ + SpaceBetweenItems)
	CanvasSizeZ = CanvasSizeZ + Number
	CurrentSlots = 0
	CurrentPosX = SpaceBetweenItems
	CurrentPosZ = CurrentPosZ + SpaceBetweenItems + SlotSizeZ
	print (CanvasSizeZ)
	script.Parent.ScrollingFrame.CanvasSize = UDim2.new(0, CanvasSizeX,0, CanvasSizeZ)
	
	
	end
	
end

wait ()
while true do
	wait ()
	CreateNewSlot()
end