Roblox’s api has:
https://api.roblox.com/ownership/hasasset?assetid=
Is there anything similar but for badges?
Roblox’s api has:
https://api.roblox.com/ownership/hasasset?assetid=
Is there anything similar but for badges?
https://developer.roblox.com/en-us/api-reference/function/BadgeService/UserHasBadgeAsync
local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")
local badgeID = 00000000 -- Change this to your badge ID
local function onPlayerAdded(player)
-- Check if the player has the badge
local success, hasBadge = pcall(function()
return BadgeService:UserHasBadgeAsync(player.UserId, badgeID)
end)
-- If there's an error, issue a warning and exit the function
if not success then
warn("Error while checking if player has badge!")
return
end
if hasBadge then
-- Handle player's badge ownership as needed
end
end
-- Connect "PlayerAdded" events to the "onPlayerAdded()" function
Players.PlayerAdded:Connect(onPlayerAdded)
Here is the API page dedicated to badges:
https://badges.roblox.com/docs#!/v1
The endpoint you are looking for would be:
https://badges.roblox.com/v1/users/{userId}/badges
This would return you a list of all gamepasses owned by the ID you input, in JSON format of course.
In lua you would use UserHasBadgeAsync().
Yes there is.
game:GetService("BadgeService"):UserHasBadgeAsync(userId, badgeId)
Example for what it can be used for:
local BS = game:GetService("BadgeService")
local badgeId = 0 --just put your own badge id there
game.Players.PlayerAdded:Connect(function(p)
if BS:UserHasBadgeAsync(p.UserId,badgeId) then
print(p.Name.." has the badge!")
end
end)