PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

GetUserId

Returns the studio user’s userId if they’re logged in, otherwise returns 0.

Returns

Return Type Summary

Code Samples


The example prints the currently logged in user’s ID.

-- Can only be used in a plugin
local StudioService = game:GetService("StudioService")
local Players = game:GetService("Players")
 
local loggedInUserId = StudioService:GetUserId()
local loggedInUserName = Players:GetNameFromUserIdAsync(loggedInUserId)
print("Hello,", loggedInUserName)