What do you want to achieve? Keep it simple and clear!
I’m working on an antivirus plugin (don’t inquire, will make free) and I’d like to be able to get the local user’s ID.
What is the issue? Include screenshots / videos if possible!
I can’t very well use game.CreatorId as in a new place, it would return the Templates user. It would also break in Team Create sessions if you don’t own the place.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t seen any ways to do this on the Developer Hub.
I would like to utilize an API to get the user’s plugin inventory, but I would need the user’s ID.
StudioService:GetUserId is the proper way to get a UserId for plugin purposes. It will return the UserId of the authenticated user for the Studio session.
LocalPlayer is nil in edit mode so you can’t get a UserId from the LocalPlayer. In the case of running a local simulation, the LocalPlayer is not guaranteed to carry the UserId of the authenticated user (an example being local servers which use negative UserIds).
(cc @Volieb)
Output reference for why LocalPlayer shouldn’t be used (local server):