Oh, I forgot that the Scale
property doesn’t always have the viewport size as the multiplier but the first GuiObject
ancestor.
You should check if there is a GuiObject
ancestor and if there is, assign to some variable the AbsoluteSize
of that GuiObject
. If there isn’t, you just assign workspace.CurrentCamera.ViewportSize
to that variable.
local ancestorsize
local guiobjancestor = v:FindFirstAncestorWhichIsA("GuiObject")
if guiobjancestor then
ancestorsize = guiobjancestor.AbsoluteSize
else
ancestorsize = workspace.CurrentCamera.ViewportSize
end
After that you replace the workspace.CurrentCamera.ViewportSize
in your code with ancestorsize
.