Attempting to use GuiService:InspectPlayerFromHumanoidDescription throws the following error:
CoreGui.RobloxGui.Modules.InspectAndBuy.Components.AvatarHeadShot:22: invalid argument #4 to ‘format’ (number expected, got string)
In CoreScripts/Modules/InspectAndBuy/Components/AvatarHeadShot
function AvatarHeadShot:render()
local playerId = self.props.playerId
local headshotUrl = HEAD_SHOT_URL:format(HEADSHOT_THUMBNAIL_SIZE, HEADSHOT_THUMBNAIL_SIZE, playerId)
...
The error is caused by playerId being a string value. When calling InspectPlayerFromHumanoidDescription no playerId is given so it seems defaults to an empty string as seen here:
In CoreScripts/CoreScripts/InspectAndBuy
local function mount(humanoidDescription, playerName, userId, ctx)
...
end
local function mountInspectAndBuyFromHumanoidDescription(humanoidDescription, playerName, ctx)
mount(humanoidDescription, playerName, nil, ctx)
end
As a temporary fix I changed the headshotUrl in AvatarHeadShot’s render function to following:
local headshotUrl = HEAD_SHOT_URL:format(HEADSHOT_THUMBNAIL_SIZE, HEADSHOT_THUMBNAIL_SIZE, typeof(playerId) == "number" and playerId or 0)
No this isn’t the cleanest fix but it shows an example.
The real question is should this be fixed this way?
The Headshot icon of the avatar is a good thing to have when inspecting a player
But when using it with a custom HumanoidDescription there is no icon to show.
I think a more suitable change would be not to render the Headshot icon there is no playerId defined. A better option would be to use ViewportFrames and make a custom headshot using the items in the menu or just give developers an ability to put any image to it
As an example changing the API to:
void
InspectPlayerFromHumanoidDescription ( Instance
humanoidDescription ,string
name ,string
icon )
There are plenty of use-cases for this feature so I hope this gets fixed soon.