Issue with Get Humanoid Description From User Id not running in a pcall

I’d like to run GetHumanoidDescriptionFromUserId() in a pcall so that if it fails, I can retry it.
The issue is, it always fails in a pcall, so I cannot apply a HumanoidDescription to a Humanoid, simply due to it not being created.

Here’s my code so far:

local positionHumanoid = ((dummyFolder:FindFirstChild(row)):FindFirstChild(position)):FindFirstChild("Humanoid")
success, response = pcall(game.Players:GetHumanoidDescriptionFromUserId(tonumber(positionvalue)))
	
if success then
	positionHumanoid:ApplyDescription(response)
end

I know that positionHumanoid works properly, and all surrounding code does so as well. The issue is in the pcall. Each time this code is run it returns success as false.

This code however does work:

local positionHumanoid = ((dummyFolder:FindFirstChild(row)):FindFirstChild(position)):FindFirstChild("Humanoid")
response = game.Players:GetHumanoidDescriptionFromUserId(tonumber(positionvalue))
positionHumanoid:ApplyDescription(response)

…but it’s not in a pcall, so I can’t use it the way I wanted to!

How can I use GetHumanoidDescriptionFromUserId() in a pcall?

Okay, I solved it myself.
I changed my code to the following:

local positionHumanoid = ((dummyFolder:FindFirstChild(row)):FindFirstChild(position)):FindFirstChild("Humanoid")
success, response = pcall(function()
	return game.Players:GetHumanoidDescriptionFromUserId(tonumber(positionvalue))
end)

if success then
	positionHumanoid:ApplyDescription(response)
end

It works as needed.
The pcall now returns the HumanoidDescription, which I didn’t make it do before.

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