Custom Badge notification

Hi devs, i have maid a custom notification system but i have a prob. Actually i want to make a system that the notification ONLY pop up when the player get for the first time the badge SO if the player already have it the notification don’t pop up. BUT IT DOESN’T WORK so if someone can help me pls.
Like how can i seperate them and check that ?

SCRIPT :

( Server Script )

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Once(function(c)
		wait(2)
		game.ReplicatedStorage.badgeAwarded:FireClient(plr, 2143789159) -- Welcome
	end)
	
	plr.CharacterAdded:Once(function(c)
		wait(2)
		game.ReplicatedStorage.badgeAwarded:FireClient(plr, 2143789186) -- Beta
	end)
	
	plr.CharacterAdded:Once(function(c)
		wait(2)
		game.ReplicatedStorage.badgeAwarded:FireClient(plr, 2143789213) -- Play With Friends
	end)
	
	plr.CharacterAdded:Once(function(c)
		wait(2)
		game.ReplicatedStorage.badgeAwarded:FireClient(plr, 2143789240) -- Group Joined
	end)
end)

( I already tried with the “has badge” etc… but still doesn’t work and this actual script just show the notification of the badge selected it doesn’t look if the player have it or no )

3 Likes

What is the code in the local script that is handling the custom badge awarded notifications?


What was the implementation using the ‘has badge’ functionality of BadgeAwardService?


Also, your code can be compressed a lot:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Once(function(c)
		wait(2)
        game.ReplicatedStorage.badgeAwarded:FireClient(plr, 2143789159) -- Welcome
        game.ReplicatedStorage.badgeAwarded:FireClient(plr, 2143789186) -- Beta
		game.ReplicatedStorage.badgeAwarded:FireClient(plr, 2143789213) -- Play With Friends
        game.ReplicatedStorage.badgeAwarded:FireClient(plr, 2143789240) -- Group Joined
	end)
end)
1 Like

Ye ik i can use that but this not what am looking for. Actually i want a script that detect if the player already have the badge or no and if no the notification pop up. Bcs actually with the script nothing are checked and the notification pop up if he has or no.

Local :

local badgeService = game:GetService("BadgeService")
local notifModule = require(script.Parent.NotifModule)

game.ReplicatedStorage.badgeAwarded.OnClientEvent:Connect(function(badgeId: number)
	local badgeData = badgeService:GetBadgeInfoAsync(badgeId)
	if badgeData then
		notifModule.createNotif(badgeData.IconImageId, badgeData.Name, badgeData.Description)
	end
end)

Module :


local notifModule = {}

local visibilityLength = 5
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Linear)
local pendingAddition = {}
local pendingDeletion = {}
local deleting = false
local adding = false


local realGoal = {}
realGoal.Size = UDim2.new(1, -10, 1, 0)
script.Parent.NotifFrame.Visible = false
local c = script.Parent.Notif:Clone()
c.Size = UDim2.new(1,-10,1,0)
c.Parent = script.Parent.NotifFrame
c.Visible = true
local realPos = c.AbsolutePosition
script.Parent.Notif.Size = UDim2.new(0, c.AbsoluteSize.X, 0, c.AbsoluteSize.Y)
c:Destroy()
script.Parent.NotifFrame.Visible = true

local function deleteNotif(notif: Frame)
	local realLeaveGoal = {}
	realLeaveGoal.Position = UDim2.new(1,10,0,0)
	local realLeaveTween = tweenService:Create(notif.Notif, tweenInfo, realLeaveGoal)
	realLeaveTween:Play()
	realLeaveTween.Completed:Wait()
	notif:Destroy()
end

function notifModule.createNotif(imageId: number, title: string, desc: string)
	while deleting do 
		task.wait()
	end
	adding = true
	local realNotif = script.Parent.Notif:Clone()
	if imageId then
		realNotif.Notif.Icon.Image = "rbxassetid://" .. tostring(imageId)
	end
	if title then
		realNotif.Notif:FindFirstChild("Name").Text = title
	end
	if desc then
		realNotif.Notif.Description.Text = desc
	end
	local fakeNotif = realNotif:Clone()
	fakeNotif.Notif.Visible = true
	fakeNotif.Parent = script.Parent
	realNotif.Size = UDim2.new(0,0,0,0)
	realNotif.Parent = script.Parent.NotifFrame
	local realTween = tweenService:Create(realNotif, tweenInfo, realGoal)
	realTween:Play()
	local fakeGoal = {}
	fakeGoal.Position = UDim2.new(0, realPos.X, 0, realPos.Y)
	fakeNotif.AnchorPoint = Vector2.new(0,0)
	fakeNotif.Position = UDim2.new(0, realPos.X, 1.112, 7)
	local fakeTween = tweenService:Create(fakeNotif, tweenInfo, fakeGoal)
	realTween:Play()
	fakeTween:Play()
	fakeTween.Completed:Wait()
	realNotif.Notif.Visible = true
	fakeNotif:Destroy()
	coroutine.wrap(function()
		task.wait(visibilityLength)
		if not deleting then
			deleting = true
			while adding do
				task.wait()
			end
			deleteNotif(realNotif)
			for i, v in pendingDeletion do
				deleteNotif(v)
			end
			pendingDeletion = {}
			deleting = false
		else
			table.insert(pendingDeletion, realNotif)
		end
	end)()
	adding = false
end

return notifModule

it’s been a while since i haven’t done anything custom but i found a video that explain how to do it pretty easily , you only need to adapt the script, https://www.youtube.com/watch?v=zGBbB5cFmGU