This is basically the successor of Roblox’s deprecated hint objects, but way more modern and customizable. Here are some use cases for this: Announcements, Tips, Warnings, Reminders, Tasks, etc.
Themes
Themes were created to allow other user to share their hint themes with everyone and make them public and easy to re-use.
How do I set the theme of a hint?
Open up the module and locate the Themes folder inside
Insert a default theme module script (go into the DefaultTheme folder to find and copy over)
Edit the the hint property table in the module to your liking.
Change the name to whatever you want.
In your LocalScript, create a new hint and set additional settings, (eg. text and visible time)
Call the SetTheme() function on your hint, and insert the name of the theme.
I strictly ask you to give me feedback on this if you chose ‘could be better’ or ‘needs improvement’
Code Sample (Creates a default hint):
local HS = require(game:GetService("ReplicatedStorage"):FindFirstChild("HintService"))
local NewHint = HS.new() -- Creates a blank, and new hint
HS.HintAdding:Connect(function(AddedHint) -- Connect this to a function to detect when a hint is added
print(string.format("The new hint that was added says '%s'", AddedHint:getLabel()))
end)
NewHint:setText("test") -- Sets the text of NewHint
NewHint:setBottomCenter() -- Sets the position of the hint to the bottom center.
NewHint:setTweenLength(5, 5) -- Sets how long the animations will last
NewHint:setTweenStyle(Enum.EasingStyle.Linear, Enum.EasingStyle.Linear) -- Sets the animation styles
NewHint:setTweenDirection(Enum.EasingDirection.In, Enum.EasingDirection.Out) -- Sets the animation directions
NewHint:broadcast(false) -- Broadcasts the hint
It’s nice but I would like it more if it changes text without making the old label disappear and the new one appear and instead tween the new text one to appear, the old one to disappear and resizing the box
Yes, but even if there is one function beginners may want to know what parameters to use and they can have a better understanding on what it does. Even thought it is pretty basic so its really your choice.
I have a few questions + improvements about the code.
DisallowedWhiteSpace is a constant, move it outside of the constructor:
function HintService.new(--[[ parameters ]])
local DisallowedWhiteSpace = {"\n", "\r", "\t", "\v", "\f"} --> move it outside this constructor
There are also a lot more constants (such as Players) that should be moved out of the constructor.
What is the purpose of this line? This just returns DisallowedWhiteSpace[1]:
local DisallowedWhiteSpace = {"\n", "\r", "\t", "\v", "\f"}
local function runThrough()
for i,v in pairs(DisallowedWhiteSpace) do
return v
end
end
if string.find(hintText, runThrough()) then
error("Whitespaces are not allowed.")
end
This snippet of code is very bloaty:
local function start()
--> code within function
end
if destroyOnFinished == true then
start()
task.wait(1)
NewHint:Destroy()
else
start()
end
This can be converted to:
--> code within function
if destroyOnFinished then
task.wait(1)
NewHint:Destroy()
end
You should also create your UI and clone it rather than creating a new one using code every single time.
local DisallowedWhiteSpace = {"\n", "\r", "\t", "\v", "\f"}
local function runThrough(hintText)
for i,v in pairs(DisallowedWhiteSpace) do
if string.find(hintText, v) then
error("Whitespaces are not allowed.")
end
end
return hintText
end
Seems cool and all, but doesn’t have much functionality. A new hint should automatically remove an existing hint but doesn’t, also doesn’t seem to have that much in control.
You know what I think would be fantastic for something like this?
The ability to stack a certain number of hints on top of each other, sort of like how Isle does it.
It prints hints in red text at the bottom of your screen that shows you what you did, what you’re not able to do, or that something is happening, and it stacks the messages if another one is already present in that spot to prevent this weird overlapping or having to wait until it goes away.
If this “service” had that mechanic, this would be 10x more useful imo.
As a mostly UI designer, I won’t personally use this unless you eventually give us the opportunity of modifying the GUI. But for those of us who don’t value interface design so much this is absolutely great!
This actually looks surprisingly similar to something I made as a reply to another notification attempt two years ago.
However, this system wasn’t perfect and had some obvious drawbacks. Reading the code of yours and I can tell its way more better structured than this two year old resource. Good job! However, mine by default allowed hints that stacked, I know you mentioned this as a new feature coming but I don’t know if it has actually been implemented yet.
P.S. Don’t disallow whitespace, developers may find use out of this (unless your system isn’t built to stand whitespace). Whitespace is an easy way to go multi-line without having to span the entire screen’s width first.