Feedback on custom BadgeService

Hi,

I have made a BadgeService that has 2 main functions
module:AwardBadge(userId: number, badgeId: number)
module:AwardBadges(userId: number, badgeIds: {number})
module:PostInChat(userId: number, badgeId: number)
and
module:GetBadgeInfoAsync(userId: number)
There is a event that gets fired when a badge is awarded.
module.BadgeAwarded:Connect(function(userId: number, badgeId: number))

Here is the link to the module.

2 Likes

Although a small module, this could be useful!
The only thing is that people who actually mass-use badgeservice probably made their own module. :sweat:

Cool nonetheless!

Yeah you are right about the mass-use part.

Thanks for the feedback!

I think this post should belong in code review not creations feedback

Oh my bad, ill change it, thanks for letting me know!

No problem! Not trying to be annoying by pointing that out, its just you wont get the comments you are looking for unless its in code review.

It is always cool and nice to see what people do with module scripts.

I would suggest you add more “methods” / functions to make it more appealing.

Nice suggestion! But I can’t really think of any more methods to add.

Maybe add :

module:GetBadgeInfo(BagdeId) -- prints its name, image, etc..
module:PostInChat(PlayerId,BadgeId) -- Posts in chat when a player has unlocked a badge
module:GiveBadges(PlayerId,{}) -- Gives the player all the badges provided in the {}.

Thanks for the suggestion! I’ll add it.

the module:GiveBadges() already exists though, its module:AwardBadges(userId: number, badgeIds: {number})

1 Like

I added the PostInChat() method but it currently does not support TextChatService
(I also added the GetBadgeInfo())

1 Like

You should make a list full of those methods in the original post

Im not saying it is, but is it possible that this is exploitable?

Because the client could just fire the function from an executer, right?

Oh yeah, my bad. I’ll do that.

I can make the module check if its called from the client or server.

How can you check that?

You can use RunService and check with RunService:IsServer()

Could you give me an example?


local module = {}

local RunService = game:GetService("RunService")

function module:CheckServer()
    return RunService:IsServer()
end

return module

And if you call it

local module = require(module)

-- on client
print(module:CheckServer()) -- returns false
-- on server
print(module:CheckServer()) -- returns true
1 Like

why do that when you could just put it in serverscriptservice
if it needs to be accessed in both the client and the server why not just replicate a client version of the module with only the client functions