I was reading i think the devforum and was tryna find out what was playeridasync
I wanna know how to get a random player id from the current server you are in. I also wanna learn how does playeridasync works, thx alott
This is what I was talking about btw
https://developer.roblox.com/en-us/api-reference/function/Players/GetUserIdFromNameAsync
GetUserIdFromNameAsync seems to be more for getting a UserId from players who are offline or not in the server. For your situation it isnt needed.
Each player instance includes a UserId attribute, so simply get the children of Players and select a random item from that array.
local Players = game.Players:GetChildren() local RandomUserId = Players[math.random(1, #Players)].UserId
Just for clarification, #
gets the number of items in a table and []
gets the place in a table correspondent to the number contained in it.
You don't need to use this to get an id of a player in the current server, just get a random number from 1 to the amount of players in the server, and then get a list of players and reference the UserId of the specified player in that list.
If you still wanted to use this, I don't know what you've done and why it's not working because the wiki link you provided even includes a code sample.