Skip to content

Instantly share code, notes, and snippets.

@cxmeel
Last active August 3, 2024 19:40
Show Gist options
  • Save cxmeel/68a95187b137e2d6ae019de8b2485f12 to your computer and use it in GitHub Desktop.
Save cxmeel/68a95187b137e2d6ae019de8b2485f12 to your computer and use it in GitHub Desktop.
local calculateScale = require(calculateScale)

local currentScale = calculateScale(myFrame)
local frameSize = frame.AbsoluteSize * currentScale

print(frameSize)
--!strict
local function calculateScale(instance: Instance)
local scaleValues = {}
local lookInside = instance
while lookInside do
local uiScale = lookInside:FindFirstChildOfClass("UIScale")
if uiScale then
table.insert(scaleValues, uiScale.Scale)
end
lookInside = lookInside.Parent
end
local totalScale = table.remove(scaleValues)
while #scaleValues > 0 do
totalScale *= table.remove(scaleValues)
end
return totalScale or 1
end
return calculateScale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment