Getting a Player's Background Image

local function GetPlayerBackground(UserID : number)
	local BGID = game:GetService('Players'):GetProfileConfigurationFromUserIdAsync(UserID).BackgroundAssetId or 0
	local Background = game:GetService('InsertService'):LoadAsset(BGID):WaitForChild('AvatarBackground')
	local BackgroundImage = Background.ImageId.Value
	local BackgroundColor = Background.Color.Value
	
	Background:Destroy()

	return BackgroundImage, BackgroundColor
end
-- example: 
local BGid, BGColor = GetPlayerBackground(PLAYER.UserId)
PlaceholderImage.Image = 'rbxassetid://'..BGid

after making this post, i wanted to figure out a way to get the actual image asset ID of the player’s background, and after a couple of minutes of experimenting i found out how to.

hope that someone finds this helpful!

11 Likes

Even better, you could ditch the Player argument entirely and take the UserID so that it works for non-joined players too. Also, destroy the Background after being done with it

3 Likes

great idea! i’ll edit it in a sec

here’s what i did with it!

9 Likes

Very very cool, will be adding to my game! Thanks for this

2 Likes

isnt UserId getting removed for User

is it getting removed entirely? i thought they’d add another variable for per game user id

UserId is not getting removed, but Roblox will soon change their TOS so that any reference to a player outside of their platform (external data-storage) will be required to use the User datatype. Which is a problem because external data-stores don’t work with it.

1 Like

Is it possible to get the HD version of an Avatar Background on the Client? As in the Image ID that’s used in the Model. Or is the Server loading in the Asset as a Model, then extracting the Image from there, required

Unfortunately this is the only method I know of, I don’t know how I could get the model without having to load it in the server first then extracting the image id from it.

1 Like

Is there a source for this supposed change they are making? Pretty sure they aren’t requiring it and any games using UserId for external data will be unaffected unless they were doing cross-game data (in which case, still a non-issue since they confirmed there will be an API to request a user’s consent for sharing their global UserId, just hopefully it does actually release before the update goes full effect)

That’s what I understood from that whole ordeal.

Also, didn’t know about this, thanks!

1 Like

thats actually pretty cool tbh

1 Like