I’m making a Mod/Admin Panel for my game, and I’m trying to make the script get the User ID of the player in the Username TextBox, This is the error I get.
local UsernameText = script.Parent.Username.Input
local UserIdText = script.Parent.UserId.Input
local function GetUserId()
local Success, UserIdResult = pcall(game.Players:GetUserIdFromNameAsync(UsernameText.Text), game.Players, UsernameText.Text)
if Success then
UserIdText.Text = tostring(UserIdResult)
end
end
UsernameText.Changed:Connect(GetUserId)
local UsernameText = script.Parent.Username.Input
local UserIdText = script.Parent.UserId.Input
local function GetUserId()
local username = UsernameText.Text
if username ~= "" then
local success, userId
local status, result = pcall(function()
userId = game.Players:GetUserIdFromNameAsync(username)
end)
if status then
UserIdText.Text = tostring(userId)
else
warn("Failed to get UserId:", result)
UserIdText.Text = ""
end
else
UserIdText.Text = ""
end
end
UsernameText.FocusLost:Connect(GetUserId)