UserService

Show Deprecated
Not Creatable
Service

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

Summary

Properties

Events

Methods


Returns an array of user information including user name and display name.

Properties

Events

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 UserInfosResponse 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 UserInfosResponse object to identify your input array with the output array.
  • It's possible to receive less UserInfoResponse objects than requested if one or more of the userIds in the request array are invalid, such as negative numbers or user ID's 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 display name associated with their account, the function will return instead the same string as the user's username in the DisplayName field. See Player.DisplayName. While a user's UserId will never change, a user may change their username or display name. 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 the method with a pcall.

Parameters

userIds: Array

An array of userIds requested.


Returns

An array of dictionary objects that contain the user's names.

Code Samples

UserService:GetUserInfosByUserIdsAsync Example

1local UserService = game:GetService("UserService")
2
3local success, result = pcall(function()
4 return UserService:GetUserInfosByUserIdsAsync({ 156, 1, 735878936 })
5end)
6
7if success then
8 for _, userInfo in ipairs(result) do
9 print("Id:", userInfo.Id)
10 print("Username:", userInfo.Username)
11 print("DisplayName:", userInfo.DisplayName)
12 end
13else
14 -- an error occurred
15end
16