TempBadgeService, an easy way to use Badges if you don't want to use/have funds!

Module - TempBadgeService

TempBadgeIcon

Welcome!

Hello! I’m dand and I’ve been scripting for a while and I came across this problem multiple times so I started this project and I think it would be helpful to small developers like myself to utilize.

This is also my first time making a Community resource so any feedback I would be grateful!


What is TempBadgeService?

It is a module created by me to help developers with little funds or people who don’t wanna spend money on Badges straight away on a game!

Basically it just holds as a subsitute until you want/can afford to use badges.

Example

First off make sure to use the Setup function so the datastore it is ready to be used. (Execute in command bar)

require(game.ServerStorage.TempBadgeService):Setup()

Lets say your game is in alpha and you’re not sure whether to spend robux on badges (aka Alpha tester badge) but you can use this module instead as a subsitute until you have a definite answer!

local TempBadgeService = require(script.TempBadgeService)

local id = TempBadgeService:CreateTempBadge('AlphaTester')

print(id) -- 2

game.Players.PlayerAdded:Connect(function(player)
  TempBadgeService:AwardTempBadge(player.UserId, id)
end)

Later in the future bind it to a real badge:

TempBadgeService:BindBadgeId(2, BadgeId) -- BadgeId is the id of a real badge.

If you think you’ve lost a badge just use this code to get its id and name!

print(TempBadgeService:GetTempBadges()) -- returns a dictionary of ids (key) and names (value)

Usage

I would suggest making as little calls as you can since it uses DataStoreService to check and store Temporary badges and if you’ve been developing for a while you know how robust it is.

Use in console command bar so it doesn’t duplicate badges with in game scripts.

Functions

CreateTempBadge(name, icon)

parameter type description
name string A name
icon string A decal link

Description: Creates a new temp badge with the given name and icon that returns the id of the new temp badge.

Returns: number


RemoveTempBadge(id)

parameter type description
id number A temp badge’s id

Description: Removes a temp badge with the given id.

Returns: nil


GetTempBadge(id)

parameter type description
id number A temp badge’s id

Description: Returns the name of the temp badge with the given id

Returns: string


GetTempBadges()

Description: Returns a dictionary with the keys being the id and the value being the name

Returns: dictionary


BindTempBadge(temp_id, real_id)

parameter type description
temp_id number A temp badge’s id
real_id number A real badge’s id

Description: Binds a temp badge with a real badge so when a player joins they get awarded the real badge.

Returns: nil


UnbindTempBadge(id)

parameter type description
id number

Description: Unbinds a temp badge from a real badge so when a player joins they don’t get awarded the real badge.

Returns: nil


AwardTempBadge(userid, id)

parameter type description
userid number A player’s userid
id number A temp badge’s id

Description: Awards a temp badge to a player so if it is/gets binded the player will be awarded.

Returns: nil


WithdrawTempBadge(userid, id)

parameter type description
userid number A player’s userid
id number A temp badge’s id

Description: Removes a temp badge from a player so the player will not be awarded.

Returns: nil


PlayerOwnsTempBadge(userid, id)

parameter type description
userid number A player’s userid
id number A temp badge’s id

Description: Returns a bool on whether a player owns the given temp badge.

Returns: boolean


Updates

If you think this could be useful please reply it’ll push me to make more updates!

  • Expect a plugin to help manage these custom badges.
  • Maybe some improvement uses with MemoryStoreService
  • Some client sided updates, will be read only.

Extras


Conclusion

Hopefully you find use in using my module!

Any bugs just private message me on the DevForum.

Thanks for reading,
Dandcx

https://www.roblox.com/library/7810969478/

11 Likes

I have some questions:

Other than that, great resource!

Helpful resource. This will help a lot of people!

Thanks for the reply,

It doesn’t but I’ll keep both in mind.

1 Like

If you don’t have the time I could go in Studio and try to implement both of these.

Quick update

Thanks to @octav20071 for the suggestions,

  1. You now get notifications when you get awarded a badge.

  2. You can set the icon of a badge by passing the link through the second parameter of CreateTempBadge, (more manipulation of icon soon)

  3. A new method WithdrawTempBadge to remove a Temp Badge from a player.

2 Likes

Ok well now this is useless because they made badges free.

9 Likes