E.g:
self.TextSize = Enum.FontSize.Size8
However, I want to be able to choose a font size by passing an argument through the function, so:
self.TextSize = Enum.FontSize.Size..tostring(FontSize)
However, this doesn’t work.
E.g:
self.TextSize = Enum.FontSize.Size8
However, I want to be able to choose a font size by passing an argument through the function, so:
self.TextSize = Enum.FontSize.Size..tostring(FontSize)
However, this doesn’t work.
self.TextSize = Enum.FontSize.Size[tostring(FontSize)]
P.S. You also use this for instances!
local part = workspace[partName]
self.TextSize = Enum.FontSize["Size" .. FontSize]
Would probably be best to either wrap this in a pcall as its prone to errors or validate the input by checking it against valid FontSize enumerations.
local TextLabel = script.Parent
local Sizes = {8, 9, 10, 11, 12, 14, 18, 24, 36, 48, 28, 32, 42, 60, 96}
local function ChangeTextSize(Size)
if not table.find(Sizes, Size) then
return
end
TextLabel.TextSize = Enum.FontSize["Size"..Size]
end
This reply was intended for the thread’s poster.