Advertisement
Achitsak

notify-ui

Mar 31st, 2025 (edited)
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.53 KB | None | 0 0
  1. -- Enhanced Sakura Notification UI for Roblox
  2. -- ธีมแจ้งเตือนซากุระแบบสวยงามสำหรับ Roblox
  3.  
  4. local SakuraPremiumNotify = {}
  5.  
  6. -- ฟังก์ชันสร้างการแจ้งเตือนแบบสวยงาม
  7. function SakuraPremiumNotify:Show(message, notifType, duration, title)
  8.     -- ค่าเริ่มต้น
  9.     message = message or "Notification message"
  10.     notifType = notifType or "Info" -- Info, Success, Warning, Error
  11.     duration = duration or 5 -- เวลาที่แสดง (วินาที)
  12.     title = title or notifType -- หัวข้อการแจ้งเตือน (ถ้าไม่กำหนดจะใช้ประเภทการแจ้งเตือน)
  13.    
  14.     -- สีตามประเภทการแจ้งเตือน
  15.     local colors = {
  16.         Info = Color3.fromRGB(173, 216, 230),      -- สีฟ้าอ่อน
  17.         Success = Color3.fromRGB(152, 223, 138),   -- สีเขียวอ่อน
  18.         Warning = Color3.fromRGB(255, 223, 126),   -- สีเหลืองอ่อน
  19.         Error = Color3.fromRGB(249, 140, 182)      -- สีชมพูอ่อน
  20.     }
  21.     local accentColor = colors[notifType]
  22.    
  23.     -- สร้าง UI
  24.     local player = game.Players.LocalPlayer
  25.     local playerGui = player:WaitForChild("PlayerGui")
  26.    
  27.     -- ตรวจสอบว่ามี ScreenGui สำหรับการแจ้งเตือนหรือไม่
  28.     local notifGui = playerGui:FindFirstChild("SakuraPremiumNotifications")
  29.     if not notifGui then
  30.         notifGui = Instance.new("ScreenGui")
  31.         notifGui.Name = "SakuraPremiumNotifications"
  32.         notifGui.ResetOnSpawn = false
  33.         notifGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  34.         notifGui.Parent = playerGui
  35.     end
  36.    
  37.     -- สร้าง Frame หลัก (ใหญ่ขึ้น)
  38.     local mainFrame = Instance.new("Frame")
  39.     mainFrame.Size = UDim2.new(0, 340, 0, 110)
  40.     mainFrame.Position = UDim2.new(1, -360, 0, 20)
  41.     mainFrame.BackgroundColor3 = Color3.fromRGB(255, 248, 252) -- สีพื้นหลังอ่อนลง
  42.     mainFrame.BackgroundTransparency = 0.05
  43.     mainFrame.BorderSizePixel = 0
  44.     mainFrame.AnchorPoint = Vector2.new(0, 0)
  45.     mainFrame.Parent = notifGui
  46.    
  47.     -- เพิ่มเอฟเฟกต์เงา
  48.     local shadow = Instance.new("ImageLabel")
  49.     shadow.Size = UDim2.new(1, 30, 1, 30)
  50.     shadow.Position = UDim2.new(0.5, 0, 0.5, 0)
  51.     shadow.BackgroundTransparency = 1
  52.     shadow.Image = "rbxassetid://6014257812"
  53.     shadow.ImageColor3 = Color3.fromRGB(0, 0, 0)
  54.     shadow.ImageTransparency = 0.6
  55.     shadow.AnchorPoint = Vector2.new(0.5, 0.5)
  56.     shadow.ZIndex = -1
  57.     shadow.Parent = mainFrame
  58.    
  59.     -- มุมโค้งสวยงาม
  60.     local UICorner = Instance.new("UICorner")
  61.     UICorner.CornerRadius = UDim.new(0, 12)
  62.     UICorner.Parent = mainFrame
  63.    
  64.     -- แถบสีด้านบนแบบสวยงาม
  65.     local accentBar = Instance.new("Frame")
  66.     accentBar.Size = UDim2.new(1, -2, 0, 6)
  67.     accentBar.Position = UDim2.new(0, 1, 0, 1)
  68.     accentBar.BackgroundColor3 = accentColor
  69.     accentBar.BorderSizePixel = 0
  70.     accentBar.Parent = mainFrame
  71.    
  72.     -- มุมโค้งสำหรับแถบสี
  73.     local accentCorner = Instance.new("UICorner")
  74.     accentCorner.CornerRadius = UDim.new(0, 12)
  75.     accentCorner.Parent = accentBar
  76.    
  77.     -- เส้นขอบสวยงาม
  78.     local border = Instance.new("UIStroke")
  79.     border.Color = Color3.fromRGB(255, 182, 193)
  80.     border.Thickness = 1.2
  81.     border.Transparency = 0.1
  82.     border.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
  83.     border.Parent = mainFrame
  84.    
  85.     -- ไอคอนตามประเภทการแจ้งเตือน
  86.     local iconIds = {
  87.         Info = "rbxassetid://3944703587",
  88.         Success = "rbxassetid://3944670656",
  89.         Warning = "rbxassetid://3944669799",
  90.         Error = "rbxassetid://3944696624"
  91.     }
  92.    
  93.     local icon = Instance.new("ImageLabel")
  94.     icon.Size = UDim2.new(0, 24, 0, 24)
  95.     icon.Position = UDim2.new(0, 15, 0, 18)
  96.     icon.BackgroundTransparency = 1
  97.     icon.Image = iconIds[notifType]
  98.     icon.ImageColor3 = accentColor
  99.     icon.Parent = mainFrame
  100.    
  101.     -- หัวข้อแจ้งเตือนแบบสวยงาม
  102.     local titleLabel = Instance.new("TextLabel")
  103.     titleLabel.Size = UDim2.new(1, -80, 0, 28)
  104.     titleLabel.Position = UDim2.new(0, 50, 0, 16)
  105.     titleLabel.BackgroundTransparency = 1
  106.     titleLabel.Text = title
  107.     titleLabel.Font = Enum.Font.GothamBold
  108.     titleLabel.TextSize = 18
  109.     titleLabel.TextColor3 = Color3.fromRGB(60, 30, 50)
  110.     titleLabel.TextXAlignment = Enum.TextXAlignment.Left
  111.     titleLabel.Parent = mainFrame
  112.    
  113.     -- ข้อความแจ้งเตือนแบบสวยงาม
  114.     local messageLabel = Instance.new("TextLabel")
  115.     messageLabel.Size = UDim2.new(1, -30, 0, 60)
  116.     messageLabel.Position = UDim2.new(0, 15, 0, 45)
  117.     messageLabel.BackgroundTransparency = 1
  118.     messageLabel.Text = message
  119.     messageLabel.Font = Enum.Font.Gotham
  120.     messageLabel.TextSize = 16
  121.     messageLabel.TextColor3 = Color3.fromRGB(90, 60, 80)
  122.     messageLabel.TextXAlignment = Enum.TextXAlignment.Left
  123.     messageLabel.TextYAlignment = Enum.TextYAlignment.Top
  124.     messageLabel.TextWrapped = true
  125.     messageLabel.Parent = mainFrame
  126.    
  127.     -- ปุ่มปิดการแจ้งเตือน
  128.     local closeButton = Instance.new("TextButton")
  129.     closeButton.Size = UDim2.new(0, 26, 0, 26)
  130.     closeButton.Position = UDim2.new(1, -35, 0, 17)
  131.     closeButton.BackgroundColor3 = Color3.fromRGB(255, 220, 230)
  132.     closeButton.Text = "×"
  133.     closeButton.TextColor3 = Color3.fromRGB(90, 60, 80)
  134.     closeButton.TextSize = 20
  135.     closeButton.Font = Enum.Font.GothamBold
  136.     closeButton.BorderSizePixel = 0
  137.     closeButton.AutoButtonColor = true
  138.     closeButton.Parent = mainFrame
  139.    
  140.     local closeCorner = Instance.new("UICorner")
  141.     closeCorner.CornerRadius = UDim.new(1, 0)
  142.     closeCorner.Parent = closeButton
  143.    
  144.     -- สร้างกลีบซากุระที่สวยงาม
  145.     local function createPetal(size, posX, posY, rotation, transparency)
  146.         local petal = Instance.new("ImageLabel")
  147.         petal.Size = UDim2.new(0, size, 0, size)
  148.         petal.BackgroundTransparency = 1
  149.         petal.Image = "rbxassetid://636768448" -- รูปกลีบซากุระ (สามารถใช้ ID อื่นได้)
  150.         petal.ImageColor3 = Color3.fromRGB(255, 182, 193)
  151.         petal.ImageTransparency = transparency
  152.         petal.Rotation = rotation
  153.         petal.AnchorPoint = Vector2.new(0.5, 0.5)
  154.         petal.Position = UDim2.new(posX, 0, posY, 0)
  155.         petal.Parent = mainFrame
  156.         return petal
  157.     end
  158.    
  159.     -- สร้างกลีบซากุระหลายๆ กลีบ
  160.     local petals = {}
  161.     table.insert(petals, createPetal(20, 0.82, 0.23, 15, 0.3))
  162.     table.insert(petals, createPetal(16, 0.88, 0.45, 30, 0.4))
  163.     table.insert(petals, createPetal(18, 0.75, 0.65, 45, 0.35))
  164.     table.insert(petals, createPetal(14, 0.92, 0.75, 60, 0.45))
  165.     table.insert(petals, createPetal(22, 0.68, 0.85, 20, 0.35))
  166.     table.insert(petals, createPetal(12, 0.25, 0.82, 70, 0.4))
  167.     table.insert(petals, createPetal(18, 0.12, 0.65, 45, 0.5))
  168.    
  169.     -- เพิ่มพื้นหลังลวดลายซากุระจางๆ
  170.     local bgPattern = Instance.new("ImageLabel")
  171.     bgPattern.Size = UDim2.new(1, 0, 1, 0)
  172.     bgPattern.BackgroundTransparency = 1
  173.     bgPattern.Image = "rbxassetid://276941193" -- รูปลวดลายซากุระ (สามารถใช้ ID อื่นได้)
  174.     bgPattern.ImageColor3 = Color3.fromRGB(255, 200, 210)
  175.     bgPattern.ImageTransparency = 0.92
  176.     bgPattern.ZIndex = 0
  177.     bgPattern.Parent = mainFrame
  178.    
  179.     -- สร้างเส้นแบ่งบรรทัดสวยงาม
  180.     local divider = Instance.new("Frame")
  181.     divider.Size = UDim2.new(1, -30, 0, 1)
  182.     divider.Position = UDim2.new(0, 15, 0, 45)
  183.     divider.BackgroundColor3 = Color3.fromRGB(255, 200, 210)
  184.     divider.BackgroundTransparency = 0.7
  185.     divider.BorderSizePixel = 0
  186.     divider.Parent = mainFrame
  187.    
  188.     -- แอนิเมชันของกลีบซากุระ
  189.     local tweenService = game:GetService("TweenService")
  190.    
  191.     for i, petal in ipairs(petals) do
  192.         spawn(function()
  193.             while mainFrame.Parent do
  194.                 local randomMovement = {
  195.                     Position = UDim2.new(
  196.                         petal.Position.X.Scale + (math.random(-10, 10) / 100),
  197.                         0,
  198.                         petal.Position.Y.Scale + (math.random(-10, 10) / 100),
  199.                         0
  200.                     ),
  201.                     Rotation = petal.Rotation + math.random(-30, 30)
  202.                 }
  203.                
  204.                 local tweenInfo = TweenInfo.new(
  205.                     math.random(3, 5),
  206.                     Enum.EasingStyle.Sine,
  207.                     Enum.EasingDirection.InOut
  208.                 )
  209.                
  210.                 local tween = tweenService:Create(petal, tweenInfo, randomMovement)
  211.                 tween:Play()
  212.                 wait(math.random(2, 4))
  213.             end
  214.         end)
  215.     end
  216.    
  217.     -- แอนิเมชันเข้า
  218.     mainFrame.Position = UDim2.new(1, 20, 0, 20)
  219.     local tweenInfo = TweenInfo.new(0.7, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
  220.     local tween = tweenService:Create(mainFrame, tweenInfo, {Position = UDim2.new(1, -360, 0, 20)})
  221.     tween:Play()
  222.    
  223.     -- เคลื่อนย้ายการแจ้งเตือนที่มีอยู่ขึ้นด้านบน
  224.     local existingNotifs = notifGui:GetChildren()
  225.     for _, notif in ipairs(existingNotifs) do
  226.         if notif ~= mainFrame and notif:IsA("Frame") then
  227.             local currentPos = notif.Position
  228.             tweenService:Create(notif, TweenInfo.new(0.5), {Position = UDim2.new(currentPos.X.Scale, currentPos.X.Offset,
  229.                                                              currentPos.Y.Scale, currentPos.Y.Offset + 120)})
  230.                           :Play()
  231.         end
  232.     end
  233.    
  234.     -- ฟังก์ชันปิดการแจ้งเตือน
  235.     local function closeNotification()
  236.         if mainFrame and mainFrame.Parent then
  237.             local fadeOut = tweenService:Create(mainFrame, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  238.                                             {Position = UDim2.new(1, 20, 0, mainFrame.Position.Y.Offset), BackgroundTransparency = 1})
  239.             fadeOut:Play()
  240.  
  241.             for _, obj in pairs(mainFrame:GetDescendants()) do
  242.                 if obj:IsA("TextLabel") or obj:IsA("TextButton") then
  243.                     tweenService:Create(obj, TweenInfo.new(0.5), {TextTransparency = 1}):Play()
  244.                 elseif obj:IsA("ImageLabel") or obj:IsA("ImageButton") then
  245.                     tweenService:Create(obj, TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
  246.                 elseif obj:IsA("Frame") then
  247.                     tweenService:Create(obj, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
  248.                 elseif obj:IsA("UIStroke") then
  249.                     tweenService:Create(obj, TweenInfo.new(0.5), {Transparency = 1}):Play()
  250.                 end
  251.             end
  252.  
  253.             -- ตรวจสอบอีกครั้งว่า mainFrame ยังอยู่ก่อนลบ
  254.             fadeOut.Completed:Connect(function()
  255.                 if mainFrame and mainFrame.Parent then
  256.                     mainFrame:Destroy()
  257.                 end
  258.             end)
  259.         end
  260.     end
  261.    
  262.     -- เชื่อมต่อปุ่มปิด
  263.     closeButton.MouseButton1Click:Connect(closeNotification)
  264.    
  265.     -- แอนิเมชันออกอัตโนมัติหลังจากครบเวลา
  266.     task.delay(duration, function()
  267.         if mainFrame and mainFrame.Parent then
  268.             closeNotification()
  269.         end
  270.     end)
  271.    
  272.     -- เพิ่มเอฟเฟกต์เมื่อเลื่อนเมาส์ไปที่การแจ้งเตือน
  273.     mainFrame.MouseEnter:Connect(function()
  274.         tweenService:Create(mainFrame, TweenInfo.new(0.3), {BackgroundColor3 = Color3.fromRGB(255, 245, 250)}):Play()
  275.         tweenService:Create(border, TweenInfo.new(0.3), {Color = accentColor}):Play()
  276.     end)
  277.    
  278.     mainFrame.MouseLeave:Connect(function()
  279.         tweenService:Create(mainFrame, TweenInfo.new(0.3), {BackgroundColor3 = Color3.fromRGB(255, 248, 252)}):Play()
  280.         tweenService:Create(border, TweenInfo.new(0.3), {Color = Color3.fromRGB(255, 182, 193)}):Play()
  281.     end)
  282.    
  283.     return mainFrame
  284. end
  285.  
  286. -- ฟังก์ชันเฉพาะสำหรับแต่ละประเภทการแจ้งเตือน
  287. function SakuraPremiumNotify:Info(message, duration, title)
  288.     return self:Show(message, "Info", duration, title or "ข้อมูล")
  289. end
  290.  
  291. function SakuraPremiumNotify:Success(message, duration, title)
  292.     return self:Show(message, "Success", duration, title or "สำเร็จ")
  293. end
  294.  
  295. function SakuraPremiumNotify:Warning(message, duration, title)
  296.     return self:Show(message, "Warning", duration, title or "คำเตือน")
  297. end
  298.  
  299. function SakuraPremiumNotify:Error(message, duration, title)
  300.     return self:Show(message, "Error", duration, title or "ข้อผิดพลาด")
  301. end
  302.  
  303. -- ฟังก์ชันแสดงผลแบบพิเศษ
  304. function SakuraPremiumNotify:CustomNotify(message, title, duration, customColor)
  305.     local notification = self:Show(message, "Info", duration, title)
  306.    
  307.     -- เปลี่ยนสีให้เป็นตามที่กำหนด
  308.     local accentBar = notification:FindFirstChild("Frame")
  309.     if accentBar then
  310.         accentBar.BackgroundColor3 = customColor or Color3.fromRGB(255, 182, 193)
  311.     end
  312.    
  313.     local icon = notification:FindFirstChild("ImageLabel")
  314.     if icon and icon.Size == UDim2.new(0, 24, 0, 24) then
  315.         icon.ImageColor3 = customColor or Color3.fromRGB(255, 182, 193)
  316.     end
  317.    
  318.     return notification
  319. end
  320.  
  321. return SakuraPremiumNotify
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement