Hey! I’ve been trying to award a badge and no matter what I do the badge doesn’t award. I’m pretty confused on what’s happening and wonder what you all think.
When the remote event is fired, the script itself runs as info on the badge is printed, and the “Christmas Badge Awarded” is also printed. The badge also has “isEnabled = true” in the info. I’ve also tried looking at other topic’s solutions, none have worked.
Completely stuck on ideas, wondering what you all think.
Thanks in advance!
local function christmas()
local player3 = game:GetService("Players"):FindFirstChildWhichIsA("Player")
local userId4 = player3.UserId
print(BadgeService:GetBadgeInfoAsync(2129845263))
BadgeService:AwardBadge(player3.UserId, 2129845263)
print("Christmas Badge Awarded")
end
game.ReplicatedStorage.ChristmasEvent.OnServerEvent:Connect(christmas)
The issue was that the script was missing the parameters for the AwardBadge function. The AwardBadge function requires two parameters, the userId and the badgeId. In this case, the userId was stored in a variable called userId4, but this variable was never passed to the AwardBadge function. We also need to pass the badgeId, which in this case is 2129845263.
To fix the issue, we need to update the AwardBadge function to include both the userId and the badgeId. The updated script should look like this:
local function christmas()
local player3 = game:GetService("Players"):FindFirstChildWhichIsA("Player")
local userId4 = player3.UserId
print(BadgeService:GetBadgeInfoAsync(2129845263))
BadgeService:AwardBadge(userId4, 2129845263)
print("Christmas Badge Awarded")
end
game.ReplicatedStorage.ChristmasEvent.OnServerEvent:Connect(christmas)
Isn’t replacing the “player3.UserId” I used in the parameters with “userId4” the same thing as the “player3.UserId” itself? I might be wrong here since I’m not the best with lua.
Anyway, I tried this and it still didn’t award the badge.
No, it isn’t the same thing. You need to pass in the actual user ID for the player you want to award the badge to. The userId4 variable is just a placeholder for the user ID of the player you want to award the badge to.