I’m attempting to make a scrolling frame that goes right to left, and left to right automatically if it’s able to…
- How would you detect if a scrolling frame is scrollable?,
- How would you detect if a scrolling frame has reached the end?,
- How would you detect if a scrolling frame has reached the beginning?
Local Script
Inside of the ScrollingFrame
local DEB = false
repeat
task.wait()
repeat
warn(script.Parent.CanvasPosition)
warn(script.Parent.AbsolutePosition)
script.Parent.CanvasPosition = Vector2.new(script.Parent.CanvasPosition.X + 50,script.Parent.CanvasPosition.Y)
task.wait(1)
until script.Parent.CanvasPosition == script.Parent.AbsolutePosition
repeat
script.Parent.CanvasPosition = Vector2.new(script.Parent.CanvasPosition.X - 50,script.Parent.CanvasPosition.Y)
task.wait(1)
until script.Parent.CanvasPosition.X == 0
until script.Disabled
How would you detect if a scrolling frame is scrollable?
Check if the ScrollingFrame’s AbsoluteCanvasSize (both x and y) are greater than its AbsoluteSize
How would you detect if a scrolling frame has reached the end?
Check if the ScrollingFrame is scrollable and its AbsoluteCanvasSize minus its CanvasPosition equals it’s AbsoluteSize
How would you detect if a scrolling frame has reached the beginning?
Check if the ScrollingFrame is scrollable and its CanvasPosition is equal to Vector2.new() (0)
local IsScrollable = false
if ScrollingFrame.AbsoluteCanvasSize.X > ScrollingFrame.AbsoluteSize.X or ScrollingFrame.AbsoluteCanvasSize.Y > ScrollingFrame.AbsoluteSize.Y then
-- ScrollingFrame.AbsoluteCanvasSize > ScrollingFrame.AbsoluteSize --> Comparing Vector2 error
print("Scrollable")
IsScrollable = true
end
...
if IsScrollable and ScrollingFrame.CanvasPosition == Vector2.new() then
print("Beginning")
end
...
if IsScrollable and ScrollingFrame.AbsoluteCanvasSize - ScrollingFrame.CanvasPosition == ScrollingFrame.AbsoluteSize then
print("End")
end
if anyone knows an easier way let me know
2 Likes