I need to make it so when an object is out of the scrolling frame view it turns invisible.
I am using the below code but judging by the gif when I scroll out of view the objects are still visible.
function isClipped(uiObject)
local parent = uiObject.Parent
local boundryTop = parent.AbsolutePosition
local boundryBot = boundryTop + parent.AbsoluteSize
local top = uiObject.AbsolutePosition
local bot = top + uiObject.AbsoluteSize
local function cmpVectors(a, b) -- Compare is a is above or to the left of b
return (a.X < b.X) or (a.Y < b.Y)
end
return cmpVectors(top, boundryTop) or cmpVectors(boundryBot, bot)
end
mainHud.Menu.CharacterScrolling:GetPropertyChangedSignal("CanvasPosition"):Connect(function() -- When It changes
for i,v in pairs(mainHud.Menu.CharacterScrolling:GetChildren()) do
if v:IsA("ImageLabel") then
if not isClipped(v) then
v.Visible = false
else
--print("invisible")
v.Visible = true
end
end
end
end)