local newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(id)
local Name = game.Players:GetNameFromUserIdAsync(id)
hum:ApplyDescription(newHumanoidDescription)
script.Parent:FindFirstChildOfClass(“Humanoid”).DisplayName = Name
This script gets a random player id and applies it to a dummy it works as usual but sometimes their is a error the error being, “Players:GetHumanoidDescriptionFromUserId() failed because HTTP 400 (Bad Request)” How do i fix this?
My guess is there’s a chance the random ID might not be good. This is a situation where it is good to wrap the function in a pcall statement.
wait()
local hum = script.Parent.Humanoid
local id
local newHumanoidDescription
local name
local successful
repeat
id = math.random(1,1000000000)
successful = pcall(function()
newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(id)
name = game.Players:GetNameFromUserIdAsync(id)
end)
until (successful)
hum:ApplyDescription(newHumanoidDescription)
script.Parent:FindFirstChildOfClass(“Humanoid”).DisplayName = name
This code will keep trying random IDs until it can successfully retrieve a humanoid description and username.