Achievements¶
Static Class
This object is a static class. It can be accessed by using it's name as a keyword like this Achievements
.
Additionally, it cannot be created in the creator menu or with Instance.New()
This is only available to the server. It can only be accessed within server scripts.
Achievements is a static class, that is used to award place achievements to a player.
Methods¶
Award → callback
¶
Parameters
playerUserID [ number
]
achievementID [ number
]
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 succeded, and "error", which contains the error message if the award failed.
HasAchievement → callback
¶
Parameters
playerUserID [ number
]
achievementID [ number
]
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.