I am trying to improve my hatch system to hatch many eggs at same time something like Pet Simulator 99.
I am blocked to how change size and position of cells in my ui to match the number of eggs.
I tried something like this but is not the good way I think.
local frame = script.Parent
local uigridlayout = script.Parent.UIGridLayout
local function calculate()
local cellCount = #frame:GetChildren() - 3
local cellSize = math.min(100, math.floor(frame.AbsoluteSize.X / math.ceil(math.sqrt(cellCount))))
uigridlayout.CellSize = UDim2.new(0, cellSize, 0, cellSize)
end
for i=1,20 do
Instance.new("Frame", frame)
calculate()
wait(0.1)
end
local frame = script.Parent --
local uigridlayout = script.Parent.UIGridLayout
local function calculate()
local cellCount = #frame:GetChildren() - 3
local cellSize = math.min(100, math.floor(frame.AbsoluteSize.X / math.ceil(math.sqrt(cellCount))))
uigridlayout.CellSize = UDim2.new(0, cellSize, 0, cellSize)
end
local player = game.Players.LocalPlayer
local char = player.Character
for i=1,99 do
Instance.new("Frame", frame)
calculate()
end