How come I can't get the correct userid?

Im trying to make a level select system where the player can only access the next level if they have the correct badge.

However GetUserIdFromNameAsync doesnt seem to be working correctly. I dont know if i’m using it the wrong way but whenever I run the script it just prints out this…

image

“73502”?

Is there any reason that it might not be the full user ID?
This is what a snippet of the script looks like, it waits for the Proximity Prompt to be trigger, then it gets the player’s userID that triggered it, checks if that ID has the badge, and if they do the script should run.

image

1 Like

You’re passing the player object into the function instead of their name.

Easy fix:

local UserId = game:GetService("Players"):GetUserIdFromNameAsync(player.Name)
print(UserId)

Give this a try and see if it works!

2 Likes

Ahhh! That seems like such a silly mistake, im still so new to scripting. Thank you, everything works now!!!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.