Hey Developers,
I’ve been having an issue on my newest game, which is making ui not scale properly when in-game. When I look in studio using mobile screen resolutions, UI looks fine and is scaled properly. When in-game, one child of the Frame, which is a Frame, is scaling improperly and overlapping with other UI elements.
The Frame is scaled using only scale and not offset, using AutoScale Lite Constraints and AutoScale SmartScale.
I have some code that tweens the UI when the UI is cloned to PlayerGui.
for i = 1,25,1 do
local Goal = {ImageColor3 = rarityThresholds[math.random(1,#rarityThresholds)].color}
roller.Frame.RarityItem.Text = rarityThresholds[math.random(1,#rarityThresholds)].name
roller.Frame.NameItem.Text = randomStrings[math.random(1,#randomStrings)]
local Tween = game:GetService("TweenService"):Create(roller.Frame.backgroundcolor, TweenInfo.new(0.04), Goal)
local Goal2 = {ImageTransparency = 0.36}
local Tween = game:GetService("TweenService"):Create(roller.Frame.ImageLabel, TweenInfo.new(0.15), Goal2)
last = 0
if roller.Frame.Frame.Rotation == -9 then
local Tween2 = game:GetService("TweenService"):Create(roller.Frame.Frame, TweenInfo.new(0.2), {Rotation = 9}):Play()
local Tween2 = game:GetService("TweenService"):Create(roller.Frame.ImageLabel, TweenInfo.new(0.2), {Rotation = 9}):Play()
last = 9
elseif roller.Frame.Frame.Rotation == 9 then
local Tween2 = game:GetService("TweenService"):Create(roller.Frame.Frame, TweenInfo.new(0.2), {Rotation = -9}):Play()
local Tween2 = game:GetService("TweenService"):Create(roller.Frame.ImageLabel, TweenInfo.new(0.2), {Rotation = -9}):Play()
last = -9
end
local randomSilhat=validHats[math.random(1,#validHats)]
Tween:Play()
roller.Frame.ImageLabel.Image = "rbxthumb://type=Asset&w=768&h=432&id="..randomSilhat
roller.Frame.Frame:TweenSizeAndPosition(UDim2.new(0, 184,0, 176),UDim2.new(0.451, 0,0.368, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.02)
roller.Frame.ImageLabel:TweenSizeAndPosition(UDim2.new(0, 192,0, 175),UDim2.new(0.448, 0,0.369, 0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.02)
wait(0.02)
roller.Frame.Frame:TweenSizeAndPosition(UDim2.new(0, 168,0, 161),UDim2.new(0.456, 0,0.368, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.02)
roller.Frame.ImageLabel:TweenSizeAndPosition(UDim2.new(0, 192,0, 159),UDim2.new(0.448, 0,0.369, 0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.02)
local Goal3 = {ImageTransparency = 1}
local Tween = game:GetService("TweenService"):Create(roller.Frame.ImageLabel, TweenInfo.new(0.2), Goal3)
wait(0.02)
wait(0.065)
end
After this for loop is completed, this tween is played, which works completely fine and scales the UI to a proper size for every device.
roller.Frame.Frame:TweenSizeAndPosition(UDim2.new(0.135, 0,0.23, 0),UDim2.new(0.432, 0,0.347, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.4)
roller.Frame.itemimage:TweenSizeAndPosition(UDim2.new(0.135, 0,0.23, 0),UDim2.new(0.432, 0,0.347, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.4)
I’m not sure why it only is improperly scaled before being scaled down, even though in previews it looks fine.