Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local ChatEvent = ReplicatedStorage:WaitForChild("ChatEvent")
- local TweenService = game:GetService("TweenService")
- local Players = game:GetService("Players")
- local player = Players.LocalPlayer
- local playerGui = script.Parent
- local unreadCount = 0
- local isChatOpened = false
- -- إنشاء الواجهة
- local gui = Instance.new("ScreenGui")
- gui.Name = "ChatUI"; gui.ResetOnSpawn = false; gui.Parent = playerGui
- -- زر فتح الشات 💬
- local openButton = Instance.new("TextButton")
- openButton.Parent = gui; openButton.Size = UDim2.new(0,70,0,70); openButton.Position = UDim2.new(0.02,0,0.5,-35)
- openButton.Text = "💬"; openButton.Font = Enum.Font.GothamBlack; openButton.TextScaled = true
- openButton.TextColor3 = Color3.new(1,1,1); openButton.BackgroundColor3 = Color3.fromRGB(25,25,25)
- Instance.new("UICorner",openButton)
- -- 🔴 دائرة الإشعارات (إصلاح الرقم)
- local notif = Instance.new("TextLabel")
- notif.Parent = openButton
- notif.Size = UDim2.new(0,25,0,25)
- notif.Position = UDim2.new(1,-18,0,-8)
- notif.BackgroundColor3 = Color3.fromRGB(220,0,0)
- notif.TextColor3 = Color3.new(1,1,1)
- notif.Text = "0"
- notif.TextScaled = true
- notif.Font = Enum.Font.GothamBold
- notif.Visible = false
- Instance.new("UICorner",notif).CornerRadius = UDim.new(1,0)
- Instance.new("UIStroke",notif).Thickness = 1.5
- -- فريم الشat
- local chatFrame = Instance.new("Frame")
- chatFrame.Parent = gui; chatFrame.Size = UDim2.new(0.32,0,0.45,0); chatFrame.Position = UDim2.new(0.08,0,0.5,-200)
- chatFrame.BackgroundColor3 = Color3.fromRGB(35,35,35); chatFrame.BackgroundTransparency = 1; chatFrame.Visible = false
- Instance.new("UICorner",chatFrame)
- local scroll = Instance.new("ScrollingFrame")
- scroll.Parent = chatFrame; scroll.Size = UDim2.new(1,-10,0.8,-10); scroll.Position = UDim2.new(0,5,0,5)
- scroll.BackgroundTransparency = 1; local layout = Instance.new("UIListLayout",scroll); layout.Padding = UDim.new(0,4)
- local box = Instance.new("TextBox")
- box.Parent = chatFrame; box.Size = UDim2.new(0.72,0,0.17,0); box.Position = UDim2.new(0.02,0,0.82,0)
- box.BackgroundColor3 = Color3.fromRGB(45,45,45); box.TextColor3 = Color3.new(1,1,1); box.PlaceholderText = "اكتب هنا..."
- Instance.new("UICorner",box)
- local sendBtn = Instance.new("TextButton")
- sendBtn.Parent = chatFrame; sendBtn.Size = UDim2.new(0.24,0,0.17,0); sendBtn.Position = UDim2.new(0.75,0,0.82,0)
- sendBtn.Text = "إرسال"; sendBtn.BackgroundColor3 = Color3.fromRGB(0, 140, 255); Instance.new("UICorner",sendBtn)
- openButton.MouseButton1Click:Connect(function()
- isChatOpened = not isChatOpened
- chatFrame.Visible = isChatOpened
- if isChatOpened then
- unreadCount = 0
- notif.Visible = false
- chatFrame.BackgroundTransparency = 0.2
- else
- chatFrame.BackgroundTransparency = 1
- end
- end)
- ChatEvent.OnClientEvent:Connect(function(senderName, message, tag, color, msgType)
- -- إظهار الرقم فوراً عند أي رسالة (حتى رسالة الدخول)
- if not isChatOpened then
- unreadCount = unreadCount + 1
- notif.Text = tostring(unreadCount)
- notif.Visible = true
- end
- local label = Instance.new("TextLabel")
- 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
- label.TextColor3 = color
- local stroke = Instance.new("UIStroke", label)
- stroke.Color = Color3.new(0,0,0); stroke.Thickness = 1.3
- if msgType == "System" then
- label.Text = "⚠️ " .. message
- elseif msgType == "Join" then
- label.TextColor3 = Color3.fromRGB(180,180,180); label.TextTransparency = 0.4; label.Text = "📥 " .. message; stroke.Enabled = false
- else
- -- الترتيب الجديد المطلوب لصانع الماب
- if tag == "OWNER" then
- label.Text = "👑 Owner " .. senderName .. ": " .. message
- else
- label.Text = senderName .. ": " .. message
- end
- end
- label.Parent = scroll
- scroll.CanvasSize = UDim2.new(0,0,0,layout.AbsoluteContentSize.Y)
- scroll.CanvasPosition = Vector2.new(0, layout.AbsoluteContentSize.Y)
- -- فقاعة الرأس
- if msgType == "" or msgType == nil then
- local char = Players:FindFirstChild(senderName) and Players[senderName].Character
- if char and char:FindFirstChild("Head") then
- if char.Head:FindFirstChild("ChatBubble") then char.Head.ChatBubble:Destroy() end
- local bill = Instance.new("BillboardGui", char.Head); bill.Size = UDim2.new(0,200,0,50); bill.StudsOffset = Vector3.new(0,3,0)
- 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)
- 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
- task.delay(4, function() if bill then bill:Destroy() end end)
- end
- end
- end)
- local function send() if box.Text ~= "" then ChatEvent:FireServer(box.Text); box.Text = "" end end
- sendBtn.MouseButton1Click:Connect(send)
- box.FocusLost:Connect(function(e) if e then send() end end)
Advertisement
Add Comment
Please, Sign In to add comment