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

How do I detect if someone is scrolling in a scrolling frame?

Asked by
trecept 367 Moderation Voter
6 years ago

I have a custom drag script, but whenever I click on the scroller in a scroll frame to scroll up, it also drags the whole GUI. Any way to detect this and not drag if the user clicks on the scroller?

1 answer

Log in to vote
1
Answered by 6 years ago

Store the ScrollFrames previous CanvasPosition in a Vector2 variable and compare it to it's current. If it's different from it then the player is scrolling.

--LocalScript
local prevPosition = Vector2.new()
local scrollFrame = script.Parent
prevPosition = scrollFrame.CanvasPosition

local runService = game:GetService("RunService")

function checkPos()
    if (prevPosition-scrollFrame.CanvasPosition).magnitude > 0 then
        --Do whatever
    end
    prevPosition = scrollFrame.CanvasPosition
end

runService:BindToRenderStep("checkPos",0,checkPos)
Ad

Answer this question