You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I would like for the text to be the same on any type of device (bigger or smaller screens)
What is the issue? If I used TextScaled it would ruin the text alot if it was 3 words they would appear super big and I didn’t want that
What solutions have you tried so far? I looked up on dev forum and the scripts people used didn’t work, AI didn’t work aswell (dont bully me but it was my last resort)
(BG is the base frame where everything is, Name is the “Theo” text, Port is the square you see on the left of Theo, and dialogue is the text label where the scaling should happen)
Also the base scale is 25
(The script i saw most use and try and also that AI sort of gave me):
local sizeOn1080 = 35 --base text size for 1080p res
local defaultWidth = 1920
local defaultHeight = 1080
local camera = workspace.CurrentCamera
local function updateTextSize()
local viewport = camera.ViewportSize
local scaleX = viewport.X / defaultWidth
local scaleY = viewport.Y / defaultHeight
local scaleFactor = math.min(scaleX, scaleY)
local newSize = sizeOn1080 * scaleFactor
script.Parent.UITextSizeConstraint.MaxTextSize = newSize
end
camera:GetPropertyChangedSignal("ViewportSize"):Connect(updateTextSize)
updateTextSize()
Basically what you should prob do is at the start grab all textlabels/uistrokes and create an attribute for their original sizes at 1920x1080. Then, you can just scale the original size according to scaleFactor every time viewport changes and on initialize. The script ai generated for you is almost there, but you just needa fix it up a bit to actually work properly and include uistrokes.
It won’t result in consistent text sizes and it would be better to use a script for text sizes. You can’t really determine a min/max text size for all devices. You can set the max to 15 for a pc user, but maybe that’s too big on a phone. Set the max to a large number, and you run into the same issue of inconsistent text sizes from textscaled (textsize alternates between large and small sizes depending on dialogue text length). I guess you could dynamically adjust uitextsizeconstraint min/max with a script, but you might as well just turn off textscaled and edit textsize directly at that point.
Thank you alot i think I get what you mean, so in roblox sudio i just get the resolution at which i did that text size, then take out a scalefactor like current res / original res and multiply the base text size to that factor? I think thats what you meant right?
for _, text in ... do
text:SetAttribute("OriginalSize") = text.TextSize
end
-- sm like this on setup
--... viewport variables yada yada
local scaleX = viewport.X / defaultWidth
local scaleY = viewport.Y / defaultHeight
local scaleFactor = math.min(scaleX, scaleY)
-- and then something like this
text.TextSize = text:GetAttribute("OriginalSize") * scaleFactor
stroke.Thickness = stroke:GetAttribute("OriginalSize") * scaleFactor
-- make this into a function and update it when necessary
of course, you might want to polish it up a bit, add a clamp to make text not become too small (or a setting for text size multiplier), etc.
I also asked an AI and it recommended a different approach. It suggested making the entire UI (or in this case, just that dialogue frame) use offset size and rewriting the scaling system to use UIScale. With this, you can set the text’s size to a fixed number and the script will adjust the frame’s UIScale which scales the UI, including the text. (feel free to bully me for asking AI )
-- Written by AI (Claude Sonnet 5)
local uiScale = script.Parent
assert(uiScale:IsA("UIScale"), "This script expects its Parent to be a UIScale instance")
local camera = workspace.CurrentCamera
-- Baseline resolution you designed the UI at
local BASELINE_X, BASELINE_Y = 1920, 1080 -- CHANGE THIS
local function updateScale()
local viewport = camera.ViewportSize
local scaleX = viewport.X / BASELINE_X
local scaleY = viewport.Y / BASELINE_Y
-- Use the smaller of the two so UI never overflows either axis
local scale = math.min(scaleX, scaleY)
-- Optional: clamp so it doesn't get absurdly tiny/huge on extreme aspect ratios
-- scale = math.clamp(scale, 0.5, 1.5)
uiScale.Scale = scale
end
camera:GetPropertyChangedSignal("ViewportSize"):Connect(updateScale)
updateScale()