Achievements
Achievements is a static class, that is used to award place achievements to a player.
The
:Award and :HasAchievement methods share a rate limit of 30 requests per minute, with an additional 10 requests per player in the server.Summary
Methods
Award:callbackHasAchievement:callback
Methods
Award
Achievements:Award(playerUserID: int, achievementID: int, callback: function): callback
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
playerUserID | int | - | |
achievementID | int | - | |
callback | function | - |
Awards the specified player the specified achievement.
Example
game["Players"].PlayerAdded:Connect(function(plr)
wait(2)
Achievements:Award(plr.UserID, 31472, function(success, error)
if success then
print("Awarded achievement")
else
print("Error awarding achievement: " .. error)
end
end)
end)
The callback function has the parameters "success", indicating if the award succeeded, and "error", which contains the error message if the award failed.
HasAchievement
Achievements:HasAchievement(playerUserID: int, achievementID: int, callback: function): callback
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
playerUserID | int | - | |
achievementID | int | - | |
callback | function | - |
Check if the specified player has the specified achievement.
Example
game["Players"].PlayerAdded:Connect(function(plr)
wait(2)
Achievements:HasAchievement(plr.UserID, 31472, function(hasAchievement, success, error)
if success then
if hasAchievement then
print(player.Name .. "has the achievement!")
else
print(player.Name .. "doesn't have the achievement :(")
end
else
print("Error checking for achievement obtainability: " .. error)
end
end)
end)
The callback function has the parameters "hasAchievement", if the player has the achievement, "success", if the lookup succeeded and "error", which contains the error message if the lookup failed.