Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I wanna learn more about playeridasync?

2 answers

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.

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.

1 comment

0

That's exactly my answer..

This discussion is preserved as it was. New answers, comments, and votes are closed.