I’m trying to position the canvas position, based on an objects position within the scrolling frame. However, since I am using a ListLayout, I can’t use it’s position property to get where it actually is in the frame.
function ShopController:ToSection(section)
local SectionLabel = HUD.Shop.Contents.Scroll:FindFirstChild(section .. "Label")
if not SectionLabel then
warn("No section for", section)
return
end
local Position = HUD.Shop.Contents.Scroll.AbsoluteCanvasSize.X * SectionLabel.Size.Y.Scale
HUD.Shop.Contents.Scroll.CanvasPosition = Vector2.new(0, Position)
print(1, HUD.Shop.Contents.Scroll.AbsoluteCanvasSize.X, SectionLabel.Size.Y.Scale)
end
holdup i might be having a stroke reading this here, so what you’re asking is for you to be able to have a scrollingframe for example be positioned on a specific item within the scrollingframe?
edit: ill try to reproduce what you’re trying to do in an hour or three since i somewhat get what you mean now, ill follow up
I was able to get to a consistent object position doing this:
local ScrollingFrame = script.Parent.ScrollingFrame
ScrollingFrame.CanvasPosition = Vector2.new(0,0)
local Position = ScrollingFrame.TextObject.AbsolutePosition.Y-ScrollingFrame.TextObject.AbsoluteSize.Y-ScrollingFrame.AbsolutePosition.Y
ScrollingFrame.CanvasPosition = Vector2.new(0,Position)
Actually I’ll just put the file here so you can check out what I’ve done. ScrollingFrame.rbxl (42.4 KB)
Might not be exactly what you’re looking for but I hope it’ll be a step to help you.
This bit shouldn’t be required as AbsolutePosition represents the GuiObject’s position from the upper-left corner of the screen. Unless the GuiObject’s AnchorPoint is set to ‘Vector2.new(0, 1)’.