Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Enhanced Sakura Notification UI for Roblox
- -- ธีมแจ้งเตือนซากุระแบบสวยงามสำหรับ Roblox
- local SakuraPremiumNotify = {}
- -- ฟังก์ชันสร้างการแจ้งเตือนแบบสวยงาม
- function SakuraPremiumNotify:Show(message, notifType, duration, title)
- -- ค่าเริ่มต้น
- message = message or "Notification message"
- notifType = notifType or "Info" -- Info, Success, Warning, Error
- duration = duration or 5 -- เวลาที่แสดง (วินาที)
- title = title or notifType -- หัวข้อการแจ้งเตือน (ถ้าไม่กำหนดจะใช้ประเภทการแจ้งเตือน)
- -- สีตามประเภทการแจ้งเตือน
- local colors = {
- Info = Color3.fromRGB(173, 216, 230), -- สีฟ้าอ่อน
- Success = Color3.fromRGB(152, 223, 138), -- สีเขียวอ่อน
- Warning = Color3.fromRGB(255, 223, 126), -- สีเหลืองอ่อน
- Error = Color3.fromRGB(249, 140, 182) -- สีชมพูอ่อน
- }
- local accentColor = colors[notifType]
- -- สร้าง UI
- local player = game.Players.LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- -- ตรวจสอบว่ามี ScreenGui สำหรับการแจ้งเตือนหรือไม่
- local notifGui = playerGui:FindFirstChild("SakuraPremiumNotifications")
- if not notifGui then
- notifGui = Instance.new("ScreenGui")
- notifGui.Name = "SakuraPremiumNotifications"
- notifGui.ResetOnSpawn = false
- notifGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- notifGui.Parent = playerGui
- end
- -- สร้าง Frame หลัก (ใหญ่ขึ้น)
- local mainFrame = Instance.new("Frame")
- mainFrame.Size = UDim2.new(0, 340, 0, 110)
- mainFrame.Position = UDim2.new(1, -360, 0, 20)
- mainFrame.BackgroundColor3 = Color3.fromRGB(255, 248, 252) -- สีพื้นหลังอ่อนลง
- mainFrame.BackgroundTransparency = 0.05
- mainFrame.BorderSizePixel = 0
- mainFrame.AnchorPoint = Vector2.new(0, 0)
- mainFrame.Parent = notifGui
- -- เพิ่มเอฟเฟกต์เงา
- local shadow = Instance.new("ImageLabel")
- shadow.Size = UDim2.new(1, 30, 1, 30)
- shadow.Position = UDim2.new(0.5, 0, 0.5, 0)
- shadow.BackgroundTransparency = 1
- shadow.Image = "rbxassetid://6014257812"
- shadow.ImageColor3 = Color3.fromRGB(0, 0, 0)
- shadow.ImageTransparency = 0.6
- shadow.AnchorPoint = Vector2.new(0.5, 0.5)
- shadow.ZIndex = -1
- shadow.Parent = mainFrame
- -- มุมโค้งสวยงาม
- local UICorner = Instance.new("UICorner")
- UICorner.CornerRadius = UDim.new(0, 12)
- UICorner.Parent = mainFrame
- -- แถบสีด้านบนแบบสวยงาม
- local accentBar = Instance.new("Frame")
- accentBar.Size = UDim2.new(1, -2, 0, 6)
- accentBar.Position = UDim2.new(0, 1, 0, 1)
- accentBar.BackgroundColor3 = accentColor
- accentBar.BorderSizePixel = 0
- accentBar.Parent = mainFrame
- -- มุมโค้งสำหรับแถบสี
- local accentCorner = Instance.new("UICorner")
- accentCorner.CornerRadius = UDim.new(0, 12)
- accentCorner.Parent = accentBar
- -- เส้นขอบสวยงาม
- local border = Instance.new("UIStroke")
- border.Color = Color3.fromRGB(255, 182, 193)
- border.Thickness = 1.2
- border.Transparency = 0.1
- border.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
- border.Parent = mainFrame
- -- ไอคอนตามประเภทการแจ้งเตือน
- local iconIds = {
- Info = "rbxassetid://3944703587",
- Success = "rbxassetid://3944670656",
- Warning = "rbxassetid://3944669799",
- Error = "rbxassetid://3944696624"
- }
- local icon = Instance.new("ImageLabel")
- icon.Size = UDim2.new(0, 24, 0, 24)
- icon.Position = UDim2.new(0, 15, 0, 18)
- icon.BackgroundTransparency = 1
- icon.Image = iconIds[notifType]
- icon.ImageColor3 = accentColor
- icon.Parent = mainFrame
- -- หัวข้อแจ้งเตือนแบบสวยงาม
- local titleLabel = Instance.new("TextLabel")
- titleLabel.Size = UDim2.new(1, -80, 0, 28)
- titleLabel.Position = UDim2.new(0, 50, 0, 16)
- titleLabel.BackgroundTransparency = 1
- titleLabel.Text = title
- titleLabel.Font = Enum.Font.GothamBold
- titleLabel.TextSize = 18
- titleLabel.TextColor3 = Color3.fromRGB(60, 30, 50)
- titleLabel.TextXAlignment = Enum.TextXAlignment.Left
- titleLabel.Parent = mainFrame
- -- ข้อความแจ้งเตือนแบบสวยงาม
- local messageLabel = Instance.new("TextLabel")
- messageLabel.Size = UDim2.new(1, -30, 0, 60)
- messageLabel.Position = UDim2.new(0, 15, 0, 45)
- messageLabel.BackgroundTransparency = 1
- messageLabel.Text = message
- messageLabel.Font = Enum.Font.Gotham
- messageLabel.TextSize = 16
- messageLabel.TextColor3 = Color3.fromRGB(90, 60, 80)
- messageLabel.TextXAlignment = Enum.TextXAlignment.Left
- messageLabel.TextYAlignment = Enum.TextYAlignment.Top
- messageLabel.TextWrapped = true
- messageLabel.Parent = mainFrame
- -- ปุ่มปิดการแจ้งเตือน
- local closeButton = Instance.new("TextButton")
- closeButton.Size = UDim2.new(0, 26, 0, 26)
- closeButton.Position = UDim2.new(1, -35, 0, 17)
- closeButton.BackgroundColor3 = Color3.fromRGB(255, 220, 230)
- closeButton.Text = "×"
- closeButton.TextColor3 = Color3.fromRGB(90, 60, 80)
- closeButton.TextSize = 20
- closeButton.Font = Enum.Font.GothamBold
- closeButton.BorderSizePixel = 0
- closeButton.AutoButtonColor = true
- closeButton.Parent = mainFrame
- local closeCorner = Instance.new("UICorner")
- closeCorner.CornerRadius = UDim.new(1, 0)
- closeCorner.Parent = closeButton
- -- สร้างกลีบซากุระที่สวยงาม
- local function createPetal(size, posX, posY, rotation, transparency)
- local petal = Instance.new("ImageLabel")
- petal.Size = UDim2.new(0, size, 0, size)
- petal.BackgroundTransparency = 1
- petal.Image = "rbxassetid://636768448" -- รูปกลีบซากุระ (สามารถใช้ ID อื่นได้)
- petal.ImageColor3 = Color3.fromRGB(255, 182, 193)
- petal.ImageTransparency = transparency
- petal.Rotation = rotation
- petal.AnchorPoint = Vector2.new(0.5, 0.5)
- petal.Position = UDim2.new(posX, 0, posY, 0)
- petal.Parent = mainFrame
- return petal
- end
- -- สร้างกลีบซากุระหลายๆ กลีบ
- local petals = {}
- table.insert(petals, createPetal(20, 0.82, 0.23, 15, 0.3))
- table.insert(petals, createPetal(16, 0.88, 0.45, 30, 0.4))
- table.insert(petals, createPetal(18, 0.75, 0.65, 45, 0.35))
- table.insert(petals, createPetal(14, 0.92, 0.75, 60, 0.45))
- table.insert(petals, createPetal(22, 0.68, 0.85, 20, 0.35))
- table.insert(petals, createPetal(12, 0.25, 0.82, 70, 0.4))
- table.insert(petals, createPetal(18, 0.12, 0.65, 45, 0.5))
- -- เพิ่มพื้นหลังลวดลายซากุระจางๆ
- local bgPattern = Instance.new("ImageLabel")
- bgPattern.Size = UDim2.new(1, 0, 1, 0)
- bgPattern.BackgroundTransparency = 1
- bgPattern.Image = "rbxassetid://276941193" -- รูปลวดลายซากุระ (สามารถใช้ ID อื่นได้)
- bgPattern.ImageColor3 = Color3.fromRGB(255, 200, 210)
- bgPattern.ImageTransparency = 0.92
- bgPattern.ZIndex = 0
- bgPattern.Parent = mainFrame
- -- สร้างเส้นแบ่งบรรทัดสวยงาม
- local divider = Instance.new("Frame")
- divider.Size = UDim2.new(1, -30, 0, 1)
- divider.Position = UDim2.new(0, 15, 0, 45)
- divider.BackgroundColor3 = Color3.fromRGB(255, 200, 210)
- divider.BackgroundTransparency = 0.7
- divider.BorderSizePixel = 0
- divider.Parent = mainFrame
- -- แอนิเมชันของกลีบซากุระ
- local tweenService = game:GetService("TweenService")
- for i, petal in ipairs(petals) do
- spawn(function()
- while mainFrame.Parent do
- local randomMovement = {
- Position = UDim2.new(
- petal.Position.X.Scale + (math.random(-10, 10) / 100),
- 0,
- petal.Position.Y.Scale + (math.random(-10, 10) / 100),
- 0
- ),
- Rotation = petal.Rotation + math.random(-30, 30)
- }
- local tweenInfo = TweenInfo.new(
- math.random(3, 5),
- Enum.EasingStyle.Sine,
- Enum.EasingDirection.InOut
- )
- local tween = tweenService:Create(petal, tweenInfo, randomMovement)
- tween:Play()
- wait(math.random(2, 4))
- end
- end)
- end
- -- แอนิเมชันเข้า
- mainFrame.Position = UDim2.new(1, 20, 0, 20)
- local tweenInfo = TweenInfo.new(0.7, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
- local tween = tweenService:Create(mainFrame, tweenInfo, {Position = UDim2.new(1, -360, 0, 20)})
- tween:Play()
- -- เคลื่อนย้ายการแจ้งเตือนที่มีอยู่ขึ้นด้านบน
- local existingNotifs = notifGui:GetChildren()
- for _, notif in ipairs(existingNotifs) do
- if notif ~= mainFrame and notif:IsA("Frame") then
- local currentPos = notif.Position
- tweenService:Create(notif, TweenInfo.new(0.5), {Position = UDim2.new(currentPos.X.Scale, currentPos.X.Offset,
- currentPos.Y.Scale, currentPos.Y.Offset + 120)})
- :Play()
- end
- end
- -- ฟังก์ชันปิดการแจ้งเตือน
- local function closeNotification()
- if mainFrame and mainFrame.Parent then
- local fadeOut = tweenService:Create(mainFrame, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
- {Position = UDim2.new(1, 20, 0, mainFrame.Position.Y.Offset), BackgroundTransparency = 1})
- fadeOut:Play()
- for _, obj in pairs(mainFrame:GetDescendants()) do
- if obj:IsA("TextLabel") or obj:IsA("TextButton") then
- tweenService:Create(obj, TweenInfo.new(0.5), {TextTransparency = 1}):Play()
- elseif obj:IsA("ImageLabel") or obj:IsA("ImageButton") then
- tweenService:Create(obj, TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
- elseif obj:IsA("Frame") then
- tweenService:Create(obj, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
- elseif obj:IsA("UIStroke") then
- tweenService:Create(obj, TweenInfo.new(0.5), {Transparency = 1}):Play()
- end
- end
- -- ตรวจสอบอีกครั้งว่า mainFrame ยังอยู่ก่อนลบ
- fadeOut.Completed:Connect(function()
- if mainFrame and mainFrame.Parent then
- mainFrame:Destroy()
- end
- end)
- end
- end
- -- เชื่อมต่อปุ่มปิด
- closeButton.MouseButton1Click:Connect(closeNotification)
- -- แอนิเมชันออกอัตโนมัติหลังจากครบเวลา
- task.delay(duration, function()
- if mainFrame and mainFrame.Parent then
- closeNotification()
- end
- end)
- -- เพิ่มเอฟเฟกต์เมื่อเลื่อนเมาส์ไปที่การแจ้งเตือน
- mainFrame.MouseEnter:Connect(function()
- tweenService:Create(mainFrame, TweenInfo.new(0.3), {BackgroundColor3 = Color3.fromRGB(255, 245, 250)}):Play()
- tweenService:Create(border, TweenInfo.new(0.3), {Color = accentColor}):Play()
- end)
- mainFrame.MouseLeave:Connect(function()
- tweenService:Create(mainFrame, TweenInfo.new(0.3), {BackgroundColor3 = Color3.fromRGB(255, 248, 252)}):Play()
- tweenService:Create(border, TweenInfo.new(0.3), {Color = Color3.fromRGB(255, 182, 193)}):Play()
- end)
- return mainFrame
- end
- -- ฟังก์ชันเฉพาะสำหรับแต่ละประเภทการแจ้งเตือน
- function SakuraPremiumNotify:Info(message, duration, title)
- return self:Show(message, "Info", duration, title or "ข้อมูล")
- end
- function SakuraPremiumNotify:Success(message, duration, title)
- return self:Show(message, "Success", duration, title or "สำเร็จ")
- end
- function SakuraPremiumNotify:Warning(message, duration, title)
- return self:Show(message, "Warning", duration, title or "คำเตือน")
- end
- function SakuraPremiumNotify:Error(message, duration, title)
- return self:Show(message, "Error", duration, title or "ข้อผิดพลาด")
- end
- -- ฟังก์ชันแสดงผลแบบพิเศษ
- function SakuraPremiumNotify:CustomNotify(message, title, duration, customColor)
- local notification = self:Show(message, "Info", duration, title)
- -- เปลี่ยนสีให้เป็นตามที่กำหนด
- local accentBar = notification:FindFirstChild("Frame")
- if accentBar then
- accentBar.BackgroundColor3 = customColor or Color3.fromRGB(255, 182, 193)
- end
- local icon = notification:FindFirstChild("ImageLabel")
- if icon and icon.Size == UDim2.new(0, 24, 0, 24) then
- icon.ImageColor3 = customColor or Color3.fromRGB(255, 182, 193)
- end
- return notification
- end
- return SakuraPremiumNotify
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement