Hello, I recently made this for fun, and testing, and decided to allow people to use it.
This module keeps caching for BadgeService requests. And does all the job for you.
I need people to help me test this, as I am not buying a badge… Lol! (Hey, roblox, can we have badge testing…?)
Functions… (only one lol)
BadgeService2.AwardBadge(plr, badgeId)
Differently from the actual BadgeService, BadgeService2 only allows you to award badges using the player object, and not their userId.
It has two arguments, 1st being the player object, and second one being the badgeId you wanna give to the player;
Example using code:
local BadgeService = require(game.ServerScriptService:WaitForChild("BadgeService2"))
local badgeId = 1285135246 -- fake number, i don't have one.
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = plr:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("Cash")
local onCashChanged
onCashChanged = cash:GetPropertyChangedSignal("Value"):Connect(function()
if cash.Value >= 230 then
BadgeService.AwardBadge(plr, badgeId)
-- Or you can do:
local awarded = BadgeService.AwardBadge(plr, badgeId)
if awarded == true then
onCashChanged:Disconnect()
end
--
end
end)
end)
This function also CAN but maybe won’t, return a value. This value will be true.
If it’s returned as true, that means that the badge was awarded before.
And you can use that data to Disconnect()
a event, which you do not need anymore.
I recommend using this method, as it helps on performance.
Module:
Again, this module is on beta, so I need feedback, with errors. Before using it on your game, check if it works. If it doesn’t then message me or reply to this.
If anybody made this before, please let me know.