Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Complete ScrollingFrame Sizing?

Asked by 9 years ago

How do I get a more accurate CanvasSize from an ScrollingFrame? Note that all the buttons that get added the frame overtime are (0, 25, 0, 25).

Currently, my size code is this:

if #Frame2:GetChildren() ~= 0 then
    script.Parent.CanvasSize = UDim2.new(0, 0, 0, #Frame2:GetChildren()*30)--what i have right now, not working.
end

1 answer

Log in to vote
-1
Answered by
woodengop 1134 Moderation Voter
9 years ago

On line 01 and 02, you are using the :GetChildren() method. GetChildren() is a read-only array of the parents properties, Use the pairs function.


for _,Frames in pairs(Frame:GetChildren()) do
    if #Frames ~= 0 then
        script.Parent.CanvasSize = UDim2.new(0, 0, 0, #Frames*30)
    end
end
0
Error: attempt to get length of local 'Frames' (a userdata value) peoplemove12 148 — 9y
Ad

Answer this question