Multiple things, first looks like you have a typo, as it should be "PlayerAdded" not "PlayersAdded".
Second thing, the function inside the event listener (for PlayerAdded) has another function inside of it called "WastedBadge". You're defining a function, but you never called it so it never ran. Now you can call it, but for simplicity, I would remove it for the code to look like so:
1 | game.Players.PlayerAdded:Connect( function (player) |
2 | player.CharacterAdded:Connect( function (character) |
3 | character.Humanoid.Died:Connect( function () |
4 | game:GetService( "BadgeService" ):AwardBadge(player.Value.UserId.BadgeID) |
Yes, remove the arguments as well, the "player" and "BadgeID".
Third, you seem to have the function duplicated above (WastedBadge), again, you can call it directly, but for now, you can remove that.
Fourth, sometimes scripts load before all of the game objects do, so it's a good habit to keep that in mind and utilize :WaitForChild() to wait for the humanoid.
So right before attaching an event listener to the humanoid, wait for it to load:
1 | local humanoid = character:WaitForChild( "Humanoid" ) |
2 | humanoid.Died:Connect( function () |
Finally, :AwardBadge() takes two arguments, the UserId of the player, and the badge Id. To pass multiple arguments to functions, you separate them with commas ","
In addition, UserId is a property of player, so you can directly do player.UserId instead of player.Value.UserId:
1 | game:GetService( "BadgeService" ):AwardBadge(player.UserId, BadgeID) |
These should be all the things you need to get it working. I would suggest trying changes on your own, and then compare it to the final result here:
04 | game.Players.PlayerAdded:Connect( function (player) |
07 | player.CharacterAdded:Connect( function (character) |
10 | local humanoid = character:WaitForChild( "Humanoid" ) |
13 | humanoid.Died:Connect( function () |
16 | game:GetService( "BadgeService" ):AwardBadge(player.UserId, BadgeID) |
Here are some helpful resources:
API reference for :WaitForChild()
https://developer.roblox.com/en-us/api-reference/function/Instance/WaitForChild
API reference for :AwardBadge() and BadgeService
https://developer.roblox.com/en-us/api-reference/function/BadgeService/AwardBadge
https://developer.roblox.com/en-us/api-reference/class/BadgeService
API reference for functions
https://developer.roblox.com/en-us/articles/Function
P.S. It's useful to have the output window open so you can check for any errors that your scripts produce.
On the tools bar above in Studio, navigate to View > Output.