Userisjsnwi949

Untitled

Jun 11th, 2026
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.66 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local ChatEvent = ReplicatedStorage:WaitForChild("ChatEvent")
  3. local TweenService = game:GetService("TweenService")
  4. local Players = game:GetService("Players")
  5.  
  6. local player = Players.LocalPlayer
  7. local playerGui = script.Parent
  8.  
  9. local unreadCount = 0
  10. local isChatOpened = false
  11.  
  12. -- إنشاء الواجهة
  13. local gui = Instance.new("ScreenGui")
  14. gui.Name = "ChatUI"; gui.ResetOnSpawn = false; gui.Parent = playerGui
  15.  
  16. -- زر فتح الشات 💬
  17. local openButton = Instance.new("TextButton")
  18. openButton.Parent = gui; openButton.Size = UDim2.new(0,70,0,70); openButton.Position = UDim2.new(0.02,0,0.5,-35)
  19. openButton.Text = "💬"; openButton.Font = Enum.Font.GothamBlack; openButton.TextScaled = true
  20. openButton.TextColor3 = Color3.new(1,1,1); openButton.BackgroundColor3 = Color3.fromRGB(25,25,25)
  21. Instance.new("UICorner",openButton)
  22.  
  23. -- 🔴 دائرة الإشعارات (إصلاح الرقم)
  24. local notif = Instance.new("TextLabel")
  25. notif.Parent = openButton
  26. notif.Size = UDim2.new(0,25,0,25)
  27. notif.Position = UDim2.new(1,-18,0,-8)
  28. notif.BackgroundColor3 = Color3.fromRGB(220,0,0)
  29. notif.TextColor3 = Color3.new(1,1,1)
  30. notif.Text = "0"
  31. notif.TextScaled = true
  32. notif.Font = Enum.Font.GothamBold
  33. notif.Visible = false
  34. Instance.new("UICorner",notif).CornerRadius = UDim.new(1,0)
  35. Instance.new("UIStroke",notif).Thickness = 1.5
  36.  
  37. -- فريم الشat
  38. local chatFrame = Instance.new("Frame")
  39. chatFrame.Parent = gui; chatFrame.Size = UDim2.new(0.32,0,0.45,0); chatFrame.Position = UDim2.new(0.08,0,0.5,-200)
  40. chatFrame.BackgroundColor3 = Color3.fromRGB(35,35,35); chatFrame.BackgroundTransparency = 1; chatFrame.Visible = false
  41. Instance.new("UICorner",chatFrame)
  42.  
  43. local scroll = Instance.new("ScrollingFrame")
  44. scroll.Parent = chatFrame; scroll.Size = UDim2.new(1,-10,0.8,-10); scroll.Position = UDim2.new(0,5,0,5)
  45. scroll.BackgroundTransparency = 1; local layout = Instance.new("UIListLayout",scroll); layout.Padding = UDim.new(0,4)
  46.  
  47. local box = Instance.new("TextBox")
  48. box.Parent = chatFrame; box.Size = UDim2.new(0.72,0,0.17,0); box.Position = UDim2.new(0.02,0,0.82,0)
  49. box.BackgroundColor3 = Color3.fromRGB(45,45,45); box.TextColor3 = Color3.new(1,1,1); box.PlaceholderText = "اكتب هنا..."
  50. Instance.new("UICorner",box)
  51.  
  52. local sendBtn = Instance.new("TextButton")
  53. sendBtn.Parent = chatFrame; sendBtn.Size = UDim2.new(0.24,0,0.17,0); sendBtn.Position = UDim2.new(0.75,0,0.82,0)
  54. sendBtn.Text = "إرسال"; sendBtn.BackgroundColor3 = Color3.fromRGB(0, 140, 255); Instance.new("UICorner",sendBtn)
  55.  
  56. openButton.MouseButton1Click:Connect(function()
  57. isChatOpened = not isChatOpened
  58. chatFrame.Visible = isChatOpened
  59. if isChatOpened then
  60. unreadCount = 0
  61. notif.Visible = false
  62. chatFrame.BackgroundTransparency = 0.2
  63. else
  64. chatFrame.BackgroundTransparency = 1
  65. end
  66. end)
  67.  
  68. ChatEvent.OnClientEvent:Connect(function(senderName, message, tag, color, msgType)
  69. -- إظهار الرقم فوراً عند أي رسالة (حتى رسالة الدخول)
  70. if not isChatOpened then
  71. unreadCount = unreadCount + 1
  72. notif.Text = tostring(unreadCount)
  73. notif.Visible = true
  74. end
  75.  
  76. local label = Instance.new("TextLabel")
  77. label.Size = UDim2.new(1,-10,0,25); label.BackgroundTransparency = 1; label.Font = Enum.Font.GothamBold; label.TextSize = 17; label.RichText = true; label.TextXAlignment = Enum.TextXAlignment.Left
  78. label.TextColor3 = color
  79.  
  80. local stroke = Instance.new("UIStroke", label)
  81. stroke.Color = Color3.new(0,0,0); stroke.Thickness = 1.3
  82.  
  83. if msgType == "System" then
  84. label.Text = "⚠️ " .. message
  85. elseif msgType == "Join" then
  86. label.TextColor3 = Color3.fromRGB(180,180,180); label.TextTransparency = 0.4; label.Text = "📥 " .. message; stroke.Enabled = false
  87. else
  88. -- الترتيب الجديد المطلوب لصانع الماب
  89. if tag == "OWNER" then
  90. label.Text = "👑 Owner " .. senderName .. ": " .. message
  91. else
  92. label.Text = senderName .. ": " .. message
  93. end
  94. end
  95.  
  96. label.Parent = scroll
  97. scroll.CanvasSize = UDim2.new(0,0,0,layout.AbsoluteContentSize.Y)
  98. scroll.CanvasPosition = Vector2.new(0, layout.AbsoluteContentSize.Y)
  99.  
  100. -- فقاعة الرأس
  101. if msgType == "" or msgType == nil then
  102. local char = Players:FindFirstChild(senderName) and Players[senderName].Character
  103. if char and char:FindFirstChild("Head") then
  104. if char.Head:FindFirstChild("ChatBubble") then char.Head.ChatBubble:Destroy() end
  105. local bill = Instance.new("BillboardGui", char.Head); bill.Size = UDim2.new(0,200,0,50); bill.StudsOffset = Vector3.new(0,3,0)
  106. local bFrame = Instance.new("Frame", bill); bFrame.Size = UDim2.new(1,0,1,0); bFrame.BackgroundColor3 = Color3.new(0,0,0); bFrame.BackgroundTransparency = 0.3; Instance.new("UICorner", bFrame)
  107. local bText = Instance.new("TextLabel", bFrame); bText.Size = UDim2.new(1,-10,1,-10); bText.Position = UDim2.new(0,5,0,5); bText.BackgroundTransparency = 1; bText.Text = message; bText.TextColor3 = color; bText.TextScaled = true; bText.Font = Enum.Font.GothamBold; Instance.new("UIStroke", bText).Thickness = 1.5
  108. task.delay(4, function() if bill then bill:Destroy() end end)
  109. end
  110. end
  111. end)
  112.  
  113. local function send() if box.Text ~= "" then ChatEvent:FireServer(box.Text); box.Text = "" end end
  114. sendBtn.MouseButton1Click:Connect(send)
  115. box.FocusLost:Connect(function(e) if e then send() end end)
  116.  
  117.  
Advertisement
Add Comment
Please, Sign In to add comment