UserService

Show Deprecated
not creatable
service

A service that handles queries regarding users on the Roblox platform.

Summary

Methods

Properties

Methods

GetUserInfosByUserIdsAsync

yields

This function enables developers to request information about users outside of the current DataModel in bulk, which is why both the input and output values are arrays.

  • The order of the user info objects in the return value's array may not match the order of the UserIds sent in the input parameter's array. Use the Id field of the user info object to identify your input array with the output array.
  • It's possible to receive fewer user info objects than requested if one or more of the UserIds in the request array are invalid, such as negative numbers or user IDs that don't have accounts associated with them. It's possible to receive a response with zero results if all UserIds are invalid.
  • If a Roblox user does not have a DisplayName associated with their account, this function will instead return the same string as the user's username in their info object's DisplayName field. While a user's UserId will never change, they may change their username or display name, so the same input UserIds may return a different string for these fields from one day to another.
  • Since GetUserInfosByUserIdsAsync() makes an external web request, it will yield and may fail if the backend service is experiencing interruptions. Ensure you can handle downtime appropriately by wrapping this method with a pcall().

The signature of a singular user info object is:

KeyTypeDescription
IdnumberThe UserId associated with the user.
UsernamestringThe username associated with the user.
DisplayNamestringThe DisplayName associated with the user.
HasVerifiedBadgebooleanThe HasVerifiedBadge value associated with the user.

Parameters

userIds: Array

An array of UserIds requested.


Returns

An array of dictionary objects that contain user information.

Code Samples

UserService:GetUserInfosByUserIdsAsync Example

local UserService = game:GetService("UserService")
local success, result = pcall(function()
return UserService:GetUserInfosByUserIdsAsync({ 156, 1, 735878936 })
end)
if success then
for _, userInfo in ipairs(result) do
print("Id:", userInfo.Id)
print("Username:", userInfo.Username)
print("DisplayName:", userInfo.DisplayName)
end
else
-- An error occurred
end

Events