Pedrinx
Key RequiredUniversal

Pedrinx

Universal ScriptPedrodjjdjPedrodjjdj 408 views 67 executesUpdated Dec 21, 2025
5.0/ 5(1 votes)
10100% Positive
Lua Script•79 lines (2369 chars)
-- 🔔 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")

Features & Information

O sistema de notificações mais fluido e estável para scripts mobile. Chega de logs poluídos e mensagens repetidas. Este script foi otimizado para garantir que cada entrada e saída seja única, elegante e funcional.

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts