I’m trying to add Character Icons into my inventory system like the ones below:
is there any way of doing this other than taking a picture of them 1 by 1?
have you tried using Enum.ThumbnailType.HeadShot
on an image label?
How would i do that? Where would the character come from?
if they’re playable characters it would come from the humanoid itself.
In this case you can use a function Players:GetUserThumbnailAsync (roblox.com)
Read to know it properly.
Here is a simple demo of how someone could use it <
- local Players = game:GetService(“Players”)
- local player = Players.LocalPlayer
- – Fetch the thumbnail
- local userId = player.UserId
- local thumbType = Enum.ThumbnailType.HeadShot
- local thumbSize = Enum.ThumbnailSize.Size420x420
- local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
This code was taken from the API reference page.
but its not the players icon, its a NPC Character
Then you might wanna use a viewport, then position the camera right in front of the character’s face and point the camera at, you guessed it, the face.
Wouldn’t a viewport for each character be laggy?
The one used in your example doesnt use Thumbnail shots, but Viewports frames. I think you should take a look into the api here
but wont using alot of Viewport frames cause lag?
Use a ViewportFrame.
Example code:
local npc = game.ReplicatedStorage.Dummy:Clone() -- create a copy of the character
local screenGui = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui) -- create a new screen gui
local viewport = Instance.new("ViewportFrame") -- create a new viewport frame
viewport.Size = UDim2.new(.19, 0, .2, 0) -- scale the frame
viewport.Parent = screenGui -- parent the frame
local camera = Instance.new("Camera") -- create a camera
camera.CFrame = CFrame.new(npc.Head.Position + Vector3.new(0, .2, 3)) -- set the cframe to the npc's head
camera.Parent = viewport -- parent the camera
viewport.CurrentCamera = camera -- set our camera as the viewport's currentcamera
npc.Parent = viewport -- parent the npc
The answer to both your questions on this is “yes,” so you’ll need to be responsible with how many are visible at any given time.
The only real alternative is to either upload the NPCs as models and use the model thumbnails or to shoot and upload your own thumbnails.