Humanoid description application not working for some players

Hello! I’ve consistently gotten feedback from some players that one of my humanoid description functions doesn’t work. The function takes a player ID input from a textbox and applies the retrieved humanoid description to a humanoid rig.

local players = game:GetService("Players")

script.Parent.FocusLost:Connect(function()
	local input = script.Parent.Text

	local success, result = pcall(
		function(inputID)
			workspace.R15HumanoidSubject2.Humanoid:ApplyDescriptionAsync(players:GetHumanoidDescriptionFromUserIdAsync(inputID))
		end,
		input)

	if not success then
		script.Parent.Text = "Application failed"
	end
end)

Players report seeing the ‘not success’ part of the function. I’ve tested the function in-game on desktop and mobile and it works fine for me, so I honestly have no idea what is going wrong here. Is something wrong with my script or are there some other factors that may cause ApplyDescriptionAsync to not work? Answers would be appreciated!

2 Likes
GetHumanoidDescriptionFromUserIdAsync()

Can fail because it does fetch data using web request. Often times when I see word Async in function names I make sure there is a function that tries it again, if it fails for several more time, I finally deem it failed. Between attempts make sure to put long enough wait 1-3 sec.

2 Likes

Thanks for responding! And apologies for the late reply. I have altered the script to include a loop that retries three times, each with increasing wait time (as well as additional checking that the input is a positive integer):

local players = game:GetService("Players")
const maxRetries = 3

script.Parent.FocusLost:Connect(function()
	local retryCount = 0
	local pass = false
	
	--Check if input is a positive integer
	local success, result = pcall(

		function(inputID)
			if tonumber(inputID) % 1 ~= 0 or tonumber(inputID) <= 0 then
				script.Parent.Text = "Invalid input"
				pass = true
			end
		end,
		script.Parent.Text)

	if not success then
		script.Parent.Text = "Invalid input"
		pass = true
	end
		
	--Loop to ensure description is actually applied
	while not pass do
		local success, result = pcall(		
			
			function(inputID)
				workspace.R15HumanoidSubject2.Humanoid:ApplyDescriptionAsync(players:GetHumanoidDescriptionFromUserIdAsync(inputID))
				pass = true
			end,
			script.Parent.Text)

		if not success then
			if retryCount < maxRetries then
				retryCount += 1
				
				script.Parent.Position = UDim2.new(-0.5, 0, 0, 0) --Move textbox off screen and replace with RetryBox to prevent editing
				script.Parent.Parent.RetryBox.Position = UDim2.new(1, 0, 0, 0)
				script.Parent.Parent.RetryBox.Text = "Retrying (" .. retryCount .. ")"
				
				task.wait(retryCount + 1)
			else
				script.Parent.Text = "Application failed"
				script.Parent.Position = UDim2.new(1, 0, 0, 0) --Move back textbox
				script.Parent.Parent.RetryBox.Position = UDim2.new(-0.5, 0, 0, 0)
				pass = true
			end
		end
	end
end)

Also, how would I got about testing the effectiveness of this change, considering that I’ve never encountered web request errors on my end? Or should I just wait for player feedback?

A bit of time has passed and I haven’t received anymore feedback about this issue, so I’ll consider this to have worked. Thank you!

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