-- 🔔 NOTIFICAÇÕES AVATAR (VERSÃO FINAL ANTI-DUPLICAR) -- 📍 StarterPlayerScripts local Players = game:GetService("Players") local StarterGui = game:GetService("StarterGui") local player = Players.LocalPlayer -- ================= TRAVA DE SEGURANÇA (GLOBAL) ================= if _G.NotificationSystemLoaded then return end _G.NotificationSystemLoaded = true local activePlayers = {} -- Tabela para controlar quem já recebeu notificação local processingQueue = {} -- Para evitar duplicação se eventos dispararem juntos -- ================= FUNÇÃO NOTIFY ================= local function Notify(title, text, userId) local iconId = "rbxthumb://type=AvatarHeadShot&id=" .. userId .. "&w=150&h=150" pcall(function() StarterGui:SetCore("SendNotification", { Title = title, Text = text, Duration = 4, Icon = iconId }) end) end -- ================= FUNÇÃO PARA ADICIONAR PLAYER ================= local function AddPlayer(p) if p == player then return end if activePlayers[p.UserId] then return end -- Evita duplicação activePlayers[p.UserId] = true Notify("Pedrin.愛!", "Bem-vindo ☄️, " .. p.Name, p.UserId) end -- ================= FUNÇÃO PARA REMOVER PLAYER ================= local function RemovePlayer(p) if p == player then return end if not activePlayers[p.UserId] then return end -- Já removido, evita duplicação activePlayers[p.UserId] = nil Notify("Pedrin.愛!", "Saída - " .. p.Name, p.UserId) end -- ================= SINCRONIZAÇÃO INICIAL ================= for _, p in ipairs(Players:GetPlayers()) do activePlayers[p.UserId] = true end -- ================= EVENTOS ================= Players.PlayerAdded:Connect(function(p) -- Processa imediatamente, mas previne duplicação if not processingQueue[p.UserId] then processingQueue[p.UserId] = true AddPlayer(p) processingQueue[p.UserId] = nil end end) Players.PlayerRemoving:Connect(function(p) if not processingQueue[p.UserId] then processingQueue[p.UserId] = true RemovePlayer(p) processingQueue[p.UserId] = nil end end) -- ================= RESET / MORTE ================= -- Se o jogador resetar, o script continua funcionando automaticamente player.CharacterAdded:Connect(function() -- Apenas reseta a própria referência do player -- Não afeta os outros, sistema continua ativo end) print("✅ SISTEMA ANTI-DUPLICIDADE ATIVADO COM SUCESSO")