I am looking for a way to get the mouse position relative to the bounds of scrolling frame.
For example: I need it so that when you scroll to the bottom of the frame and put your mouse at the bottom, then it would show the bottom Y of the frame.
Not sure how to explain it well, but I hope that explains what I’m wanting.
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local screenGui = script.Parent
local scrollingFrame = screenGui:WaitForChild("ScrollingFrame")
local function getmousePOS()
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local mouseX, mouseY = mouse.X, mouse.Y
local framePosition = scrollingFrame.AbsolutePosition
local frameSize = scrollingFrame.AbsoluteSize
local relativeX = mouseX - framePosition.X
local relativeY = mouseY - framePosition.Y
local scrollPosition = scrollingFrame.CanvasPosition
relativeX = relativeX + scrollPosition.X
relativeY = relativeY + scrollPosition.Y
if relativeX < 0 then relativeX = 0 end
if relativeY < 0 then relativeY = 0 end
if relativeX > frameSize.X then relativeX = frameSize.X end
if relativeY > frameSize.Y then relativeY = frameSize.Y end
return relativeX, relativeY
end