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