So I was making a word processing software inside roblox (For simulation purposes, I am not trying to compete with large word processing softwares and it wasn’t intended for profiting off it). Anyway, I was trying to change the font of a textbox when a button is clicked.
So:
What do you want to achieve? A button that changes font of a textbox.
What is the issue? I can’t seem to make it work.
What solutions have you tried so far? Checked online but I can’t find one.
Font is already a property of the TextBox so you don’t do TextBox.Text.Font, instead you do TextBox.Font. Also I would personally prefer using string for the font since it is faster to type xD
The font which is changing is in the Starter Gui
Everything replicates to player gui.
Therefore instead of addressing like that go through the parents
eg script.Parent…
local TextBox = -- set this to the textbox but se script.Parent, script.Parent.Parent, etc.
script.Parent.MouseButton1Click:Connect(function()
TextBox.Font = "AmaticSC"
end)
I just realized a mistake in the code. This code actually changes the TextBox in the StarterGui… You should change the TextBox inside the PlayerGui. Here is the new code
Whether or not that is necessarily good practice is a different story though. You also can’t compare fonts the same way. (Enum.Font.SourceSans ~= "SourceSans")
So for consistency you may not want to do that. There’s also the argument that it could perform better, as no implicit casting is done from string → Enum.Font, but that’s mostly negligible. You should run a test though.
True, Enum.Font may perform better than using strings. I just started coding so I don’t prioritize script performance yet lol. But yes, like I said, it is just a personal preference, I don’t recommend anybody to use strings if it performs slower than Enum.Font.
(also let’s stop this conversation since this solved post keeps getting revived xD)