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

Can anyone help when I try to find a player's userid, I get an error (look below)?

I'm trying to get a textbox that finds a player's userid from entering their name. Script:

lua
local username = game.ReplicatedStorage.Value.Value
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
    local userID = game.Players:GetUserIdFromNameAsync(username)
    wait(5)
    game.Workspace.R15Loader.Configuration.userId.Value = userID
end)

I keep getting this output: Players:GetUserIdFromName() failed because the user does not exist.

Before I put in local username and the remote event, where it says (username), I put ("somerandomuser") and it would load, but now it won't.

2 comments

0

i do game.Players.LocalPlayer.UserId and it usually works

0

This is a one player game, though and others aren't in the game.

1 answer

Shufle i already answered this on discord

the first param is the player and the second is ur your username arg which you pass

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, username)
    local userID = game.Players:GetUserIdFromNameAsync(username)
    wait(5)
    game.Workspace.R15Loader.Configuration.userId.Value = userID
end)

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