I dont know why sometimes thickness_six becomes 0.006?
local camera = workspace.CurrentCamera
local VIEWPORT_SIZE = Vector2.new(1920, 1080)
repeat
task.wait()
until
camera.ViewportSize.X ~= 0 and camera.ViewportSize.Y ~= 0
local function getBox(vector2: Vector2): number
return math.min(vector2.X, vector2.Y)
end
local function getScreenRatio(): number
return getBox(camera.ViewportSize) / getBox(VIEWPORT_SIZE)
end
local thicknesses = {
thickness_six = 6
}
for name, thickness in thicknesses do
thicknesses[name] = thickness * getScreenRatio()
end
return thicknesses
Because there’s a moment when ViewportSize is (1, 1) I think, and that’s when the code runs. You should use :GetPropertyChangedSignal() for this.
for name, thickness in thicknesses do
thicknesses[name] = thickness * getScreenRatio()
end
camera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
for name, thickness in thicknesses do
thicknesses[name] = thickness * getScreenRatio()
end
end
Is there a reason you aren’t checking for ViewportSize updates in general? The player could always resize their window, making the UIStroke thickness look really bad if they were to join the game with a small square res, then fullscreen with something like a 2560 x 1440 monitor
@ys3741 has a good solution for that exact thing, should fix the issue you’re experiencing