hello devlopers, I’m having a problem with the scrollingframe because it is not “Rendering” the frames (children)
Here is the script used to organize the ScrollingFrame:
local FrameLobbyName = "Lobby"
local Bases = workspace:WaitForChild("Bases")
local ScrollingFrame = script.Parent.Frame.Frame.ScrollingFrame
for p = 1,#Bases:GetChildren() do
local Clone = script.Sample:Clone()
Clone.Name = "Stage"..p
Clone.Stage.Text = "Stage"..p
Clone.ButtonFrame.Button.Number.Value = p
Clone.Parent = script.Parent.Frame.Frame.ScrollingFrame
ScrollingFrame.CanvasSize = UDim2.new(0,0,0,ScrollingFrame.UIListLayout.AbsoluteContentSize.Y)
end
(NOTE: the “Bases” Model has 12 children!)
Here is the scrollingframe before the script (Initial):
Here is the scrollingframe After the script:
Here is how the scrolling frame looks in the game:
(I don’t know why, but when the scrollingframe is being executed by the script it does not consider the 12 frames, it only considers 9, if someone can help me I will be very happy!)
Something silly about UIListLayout.AbsoluteContentSize is that it does not update immediately right after adding GUI objects to its parent. You need to wait a frame before it decides to update.
The problem is that you’re updating the CanvasSize inside the for loop. Don’t. Move the updating of CanvasSize outside of the for loop. It is also worth noting that this takes out how much re-rendering the Gui engine does because it will only update CanvasSize after all the elements are filled rather than as it is adding.
By the way, if you don’t need scale and are only working with offset, you can use the fromOffset constructor. You only need to pass two values, the offsets for X and Y. Scale will be automatically filled with 0s (format {0, x}, {0, y}).
for i = 1, #Bases:GetChildren() do
-- Perform
end
ScrollingFrame.CanvasSize = UDim2.fromOffset(0, ScrollingFrame.UIListLayout.AbsoluteContentSize.Y)
@Razorter Adding a wait to attempt to solve timing problems is a code smell. You should never try fixing problems with wait without significant reason. This does not include the wait method of RBXScriptConnections which still retains an event-based environment.
Have you checked to ensure all 12 children of the bases model have loaded before your script executes? It might be that they’re not physically there when the script is run so the script has only picked up 9 of them.
Try putting this before your loop, and see if it prints 12 to the output: print(#Bases:GetChildren())
That’d work! haha.
But in reference to your previous message, you should really be handing player data on the server, and communicating with it via RemoteFunctions and RemoteEvents. This should not be accessible on the client.