Advertisement
Vortex23

Notification-Library

Aug 5th, 2024 (edited)
84,999
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.67 KB | None | 0 0
  1. -- Script by IceMinister#9889
  2. local LibraryName = "Notification Library" -- yes
  3. local NotificationLibrary = {}
  4. local TweenService = game:GetService("TweenService")
  5. local CoreGui = cloneref(game:GetService("CoreGui")) --plr.PlayerGui
  6. local library
  7. local templateFolder
  8. local canvas
  9. function NotificationLibrary:Load()
  10.     library = game:GetObjects("rbxassetid://15133757123")[1]
  11.     templateFolder = library.Templates
  12.     canvas = library.list
  13.     library.Name = LibraryName
  14.     library.Parent = CoreGui
  15. end
  16. function NotificationLibrary:SendNotification(Mode, Text, Duration)
  17.     local libaryCore = CoreGui:FindFirstChild(LibraryName)
  18.     if not CoreGui:FindFirstChild(LibraryName) then
  19.         NotificationLibrary:Load()
  20.     else
  21.         library = libaryCore
  22.         templateFolder = library.Templates
  23.         canvas = library.list
  24.     end
  25.     if templateFolder:FindFirstChild(Mode) then
  26.         task.spawn(function()
  27.             local success, err = pcall(function()
  28.                 local Notification = templateFolder:WaitForChild(Mode):Clone()
  29.                 local filler = Notification.Filler
  30.                 local bar = Notification.bar
  31.                 Notification.Header.Text = Text
  32.                
  33.                 Notification.Visible = true
  34.                 Notification.Parent = canvas
  35.    
  36.                 Notification.Size = UDim2.new(0, 0,0.087, 0)
  37.                 filler.Size = UDim2.new(1, 0,1, 0)
  38.        
  39.                 local T1 = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
  40.                 local T2 = TweenInfo.new(Duration, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
  41.                 local T3 = TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
  42.            
  43.                 TweenService:Create(Notification, T1, {Size = UDim2.new(1, 0,0.087, 0)}):Play()
  44.                 task.wait(0.2)
  45.                 TweenService:Create(filler, T3, {Size = UDim2.new(0.011, 0,1, 0)}):Play()
  46.            
  47.                 TweenService:Create(bar, T2, {Size = UDim2.new(1, 0,0.05, 0)}):Play()
  48.            
  49.                 task.wait(Duration)
  50.            
  51.                 TweenService:Create(filler, T1, {Size = UDim2.new(1, 0,1, 0)}):Play()
  52.                 task.wait(0.25)
  53.                 TweenService:Create(Notification, T3, {Size = UDim2.new(0, 0,0.087, 0)}):Play()
  54.                 task.wait(0.25)
  55.                 Notification:Destroy()
  56.             end)
  57.             if not success then
  58.                 warn("There was an error while trying to create an notification!")
  59.                 warn(err)
  60.             end
  61.         end)
  62.     else
  63.         warn("Invalid theme applyed")
  64.     end
  65. end
  66.  
  67.  
  68. return NotificationLibrary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement