01 | local Players = game:GetService( "Players" ) |
02 | local Bird = script.Parent:WaitForChild( "Humanoid" ) |
03 | local BadgeService = game:GetService( "BadgeService" ) |
04 |
05 | local BadgeID = 0 --I haven't made a badge yet |
06 |
07 | while true do |
08 | if Bird.Died then |
09 | local players = game:GetService( "Players" ):GetPlayers() |
10 | BadgeService:AwardBadge(players.UserID, BadgeID) |
11 | end |
12 | end |
When I run this script it says: Argument 1 missing or nil - Server - Script:10 Stack Begin - Studio Script 'Workspace.FenceDimorphodon.Script', Line 10 - Studio - Script:10 Stack End - Studio
Why is it saying that? I'd really appreciate anyone who can help me!
in line 9
1 | local players = game:GetService( "Players" ):GetPlayers() |
you get a table with all the players so in line 10
1 | BadgeService:AwardBadge(players.UserID, BadgeID) |
you ask for a specific userID from a table that contains all Players, you don't specify which user you want to get the id from
if you want to give the badge to all players you do
1 | for _, player in pairs (players) do |
2 | BadgeService:AwardBadge(player.UserID, BadgeID) |
3 | end |