I have this script were I’m Trying to make it where If a Player has bought a different game it will give them a badge. But It’s not giving them the Badge to the Player.
There’s No Errors on the Output soo idk why it’s not doing anything.
local plr = game.Players.LocalPlayer
local MPS = game.MarketplaceService
local gameID = script.Configuration.GameID
local Badge = game:GetService("BadgeService")
local BadgetId = 2126951965
game.Players.PlayerAdded:Connect(function(plr)
hasAccess = MPS:PlayerOwnsAsset(plr, gameID.Value)
if hasAccess then
Badge:AwardBadge(plr.userId,BadgetId)
else
end
end)
this script is some example from roblox, will work, because works fine here
needs some adaptation only
local BadgeService = game:GetService("BadgeService")
local badgeId = 2126951965 -- example
game.Players.PlayerAdded:Connect(function(player)
local function AwardBadge(player, badgeId)
print"Awarding some badge"
print(badgeId)
task.wait(1)
-- Fetch badge information
local success, badgeInfo = pcall(function()
return BadgeService:GetBadgeInfoAsync(badgeId)
end)
if success then
-- Confirm that badge can be awarded
if badgeInfo.IsEnabled then
-- Award badge
local awarded, errorMessage = pcall(function()
BadgeService:AwardBadge(player.UserId, badgeId) ------- [badge id here]
end)
if not awarded then
warn("Error while awarding badge:", errorMessage)
end
end
else
warn("Error while fetching badge info!")
end
end
end)
chill, that’s okay, we are here to learn, and yes, it all go in the same script, i recommend you to watch some tutorials about scripting, you will be rlly good in a few weeks, depending on your mind efforts, trust me, when you understand what you are doing, you never will see roblox studio as the same again, you will feel a light on your head
This is just a free modeled badge script, it doesn’t even work (‘AwardBadge’ is never called). The thread’s poster is looking for a script that awards a player a badge if that player has bought access to a game.
local Game = game
local BadgeService = Game:GetService("BadgeService")
local MarketplaceService = Game:GetService("MarketplaceService")
local PlayersService = Game:GetService("Players")
local GameId = 0 --This needs to be the game's universe ID (not its place ID).
local BadgeId = 0 --ID of the badge to award.
local function OnPlayerAdded(Player)
local Success, Result = pcall(function() return MarketplaceService:PlayerOwnsAsset(Player, GameId) end)
if not Success then warn(Result) end
if not Result then return end --User hasn't bought access to the game.
Success, Result = pcall(function() return BadgeService:UserHasBadgeAsync(Player.UserId, BadgeId) end)
if not Success then warn(Result) end
if Result then return end --User has already been awarded the badge.
Success, Result = pcall(function() return BadgeService:AwardBadge(Player.UserId, BadgeId) end)
if not Success then warn(Result) end
end
PlayersService.PlayerAdded:Connect(OnPlayerAdded)