Advertisement
joefromsansnite

Untitled

Nov 24th, 2021
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. --!nocheck
  2. local Notification = {}
  3.  
  4.  
  5. -----<| SERVICES |>-----
  6. local TweenService = game:GetService("TweenService")
  7.  
  8.  
  9. -----<| PLAYER |>-----
  10. local player: Player = game:GetService("Players").LocalPlayer
  11. local playerGui: PlayerGui = player:WaitForChild("PlayerGui")
  12.  
  13.  
  14. -----<| GUI |>-----
  15. local UI: ScreenGui = script:WaitForChild("Notification")
  16.  
  17.  
  18. -----<| NOTIFICATION TYPE |>-----
  19. type Notification = {
  20. Title: string,
  21. Description: string,
  22. Button1: boolean,
  23. Button2: boolean,
  24. Callback1: any,
  25. Callback2: any
  26. }
  27.  
  28.  
  29. function Notification:Notify(args: Notification)
  30. assert(type(args.Callback1) == "function", "![[ Callback1 must be a function ]]!")
  31. assert(type(args.Callback2) == "function", "![[ Callback2 must be a function ]]!")
  32.  
  33.  
  34. -----<| DUPLICATE GUI |>-----
  35. local NewUI: ScreenGui = UI:clone()
  36. local Menu: Frame = NewUI:WaitForChild("Menu")
  37. local Background: Frame, Exit: ImageButton, Title: TextLabel = Menu:WaitForChild("Background"), Menu:WaitForChild("Exit"), Menu:WaitForChild("Title")
  38. local Buttons: Frame, Description: TextLabel = Background:WaitForChild("Buttons"), Background:WaitForChild("Description")
  39. local Okay: Folder, YesNo: Folder = Buttons:WaitForChild("Okay"), Buttons:WaitForChild("YesNo")
  40. local OkayButton: TextButton = Okay:WaitForChild("Okay")
  41. local YesButton: TextButton, NoButton: TextButton = YesNo:WaitForChild("Yes"), YesNo:WaitForChild("No")
  42.  
  43. NewUI.Parent = playerGui
  44.  
  45.  
  46. -----<| VARIABLES |>-----
  47. local buttons =
  48. {
  49. ["Okay"] =
  50. {
  51. ["Button"] = OkayButton,
  52. ["Callback"] = args.Callback1
  53. },
  54. ["Yes"] =
  55. {
  56. ["Button"] = YesButton,
  57. ["Callback"] = args.Callback1
  58. },
  59. ["No"] =
  60. {
  61. ["Button"] = NoButton,
  62. ["Callback"] = args.Callback2
  63. },
  64. }
  65.  
  66.  
  67. -----<| FUNCTIONS |>-----
  68. local function CloseUI(close: boolean)
  69. local properties = (close) and {Position = UDim2.new(0.5, 0, 1.2, 0)} or {Position = UDim2.new(0.5, 0, 0.35, 0)}
  70. local info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
  71.  
  72. local tween = TweenService:Create(Menu, info, properties)
  73.  
  74. tween:Play()
  75. tween.Completed:Connect(function()
  76. if close then
  77. NewUI:Destroy()
  78. end
  79. end)
  80. end
  81. local function SetInfo()
  82. Title.Text = args.Title
  83. Description.Text = args.Description
  84. end
  85. local function SetDraggable(draggable: boolean)
  86. Menu.Active = draggable
  87. Menu.Draggable = draggable
  88. end
  89. local function ShowButtons()
  90. OkayButton.Visible = (args.Button1 and not args.Button2) and true or false
  91. YesButton.Visible, NoButton.Visible = (args.Button1 and args.Button2) and true or false, (args.Button1 and args.Button2) and true or false
  92. end
  93. local function OnButtonsClick()
  94. for _, button in pairs(buttons) do
  95. button["Button"].MouseButton1Click:Connect(function()
  96. CloseUI(true)
  97. button["Callback"]()
  98. end)
  99. end
  100. end
  101.  
  102. -----<| CALL FUNCTIONS |>-----
  103. CloseUI(false)
  104. SetDraggable(true)
  105. SetInfo()
  106. OnButtonsClick()
  107. ShowButtons()
  108. end
  109.  
  110. return Notification
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement