Update GUI with live appearance

Hi everyone!

I’m stuck again working on the script for my GUI HUD.
I used a free model to put the image of the avatar of the player onscreen.

Then I added some stuff to make it flash and play a sound when you take damage.

The problem is that this code is based upon the thumbnail image of the avatar from the website.
What would I use to update it with the players live appearance so that if they unlock a hat or a different face in the game, that it updates on their HUD as well?

Here is what I currently use:

local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")

local Player = Players.LocalPlayer
local Character = Workspace:WaitForChild(Player.Name)
local Humanoid = Character:WaitForChild("Humanoid")

local UI = Player.PlayerGui:WaitForChild("UI")
local Elements = UI:WaitForChild("Elements")

local User = Elements:WaitForChild("User")

local Avatar = User:WaitForChild("Avatar")

Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..Player.UserId.."&width=420&height=420&format=png"


local player = game.Players.LocalPlayer
local function onHealthChanged()
		if Humanoid.Health <= 0 then
			Avatar.BackgroundTransparency = 0
			wait(10)
			Avatar.BackgroundTransparency = 1
			print("Dead!")
		else
			print("Damage Taken")
			Avatar.BackgroundTransparency = 0
			game.Workspace.Sounds.Oof:Play()
			wait(0.1)
			Avatar.BackgroundTransparency = 1
			end
	end

local function onCharacterAdded(character)
	local human = character:WaitForChild("Humanoid")
	-- Pattern: update once now, then any time the health changes
	human.HealthChanged:Connect(onHealthChanged)
	onHealthChanged()
end
 
-- Connect our spawn listener; call it if already spawned
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
	onCharacterAdded(player.Character)
end

I also tried using Players:GetCharacterAppearanceAsync, but I couldn’t figure out how to get it onto the HUD. It would throw an error that said it was an unexpected URL

Thanks for reading as always

I don’t think thats possible if you’re getting the image from the user’s profile. It wont update if you just tried to slap on a hat on the character. If you really wanted to do this, you could try getting the character and use Viewportframes to show the character and update it when it equips a hat or so. This also means that you can do some pretty cool things such as a rotating character view or showing its movement like how they do it in Arsenal : Arsenal - Roblox

Simply put, you cant show what its wearing simply by getting the character’s image from the ROBLOX website. The only way that will update is if the player wore something on their avatar.

4 Likes