So this isn’t as cool as a lot of the resources I see on here, but I would love to be able to share it. This is my simple notification system. Its simple enough for new developers to use and understand, clear commented aswell. Ill tell you how to use it below:
MODULE:
local TweenServ = game:GetService("TweenService")
local Notifications = {}
function Notifications:Notify(message: string, delay: number, player: Player | "All")
local function sendNotification(player)
local playerGui = player:FindFirstChild("PlayerGui")
-- You could add a check to return if the PlayerGui isn't loaded,
-- but most likely you wont need it as you'll probably run this when the server started already
-- Clone the template UI from the module script (Create a textlabel called "Template" and make it a child of the module)
local templateClone = script.Template:Clone()
templateClone.Text = message
templateClone.Parent = playerGui.Notify.MainContainer
-- Set initial transparency
templateClone.TextTransparency = 1
-- Create a simple fade-in and fade-out tween
local tweenIn = TweenServ:Create(templateClone, TweenInfo.new(0.5), {TextTransparency = 0})
local tweenOut = TweenServ:Create(templateClone, TweenInfo.new(0.5), {TextTransparency = 1})
-- Play tweens
tweenIn:Play()
task.delay(delay, function()
tweenOut:Play()
tweenOut.Completed:Wait()
templateClone:Destroy()
end)
end
-- Check if we want to notify all players or a specific one
if player == "All" then
for _, allPlayers in pairs(game.Players:GetPlayers()) do
sendNotification(allPlayers)
end
else
sendNotification(player)
end
end
return Notifications
So firstly, create a TextLabel named “Template”, and make it a child of your Module. Create a ScreenGui called “Notify”, and add a frame called “MainContainer” as the child. Make sure to add a UIListLayout in the frame. Now we’ll create a server script, my example just shows how we can use it as a game-wide message, but you can use it however you like:
SERVER SCRIPT:
local MessageService = game:GetService("MessagingService")
local Notifications = require(game.ReplicatedStorage.Modules.NotificationService)
MessageService:SubscribeAsync("GlobalNotification", function(message)
task.wait(3)
Notifications:Notify(message.Data, 3, "All")
end)
MessageService:PublishAsync("GlobalNotification", "Bob is a nerd")
And the result?
This is my second resource, so if there’s anything I could do better, or if you just have any questions please let me know