I’m sure I’ve seen something like this on these forums, but they didn’t ask the specific question I was going to ask.
So basically, I’m trying to create a GUI thing where you click your profile picture (something like the example shown below) to get settings, e.c.t. I’m not sure how exactly I would do it. I’ve heard it needs a specific link, but I can’t seem to find it. Could anyone help?
2022 edit: Wow, I’m beyond surprised that this has a lot of views, not to brag or anything. I hope this has helped you!
You need to further get the localplayer. At the moment, you’re trying to get a UserId from the players service.
Like this:
local player = players.LocalPlayer
Then swap in player
Also, yes. The GetUserThumbnailsAsync method will return a URL which is guaranteed to be correct, so you don’t have to format your URL yourself. Also, it has the added benefit that you can get different types of thumbnail, like head shot, bust and full avatar.
You said you want to get the head shot of the avatar. Simply use this code:
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)
-- Set the ImageLabel's content to the user thumbnail
local imageLabel = script.Parent
imageLabel.Image = content
imageLabel.Size = UDim2.new(0, 420, 0, 420)
Note that all this info is off the developer hub post, so maybe check there before you try and come up with your own method for doing this with API endpoints.
I’m trying to display a picture of the user that owns a tycoon onto a surface gui through a serverscript, mind telling me how you did that? Also, sorry for ‘necrobumping’ the thread but I’ve been looking for a way on how to do this for a while.
anyway, here’s the script I currently have that isn’t working if anyone decides to help.
local Players = game:GetService("Players")
local Profile = script.Parent
local Display = Profile.Display
local ImageLabel = Display.ImageLabel
local Owner = script.Parent.Parent.Parent.Parent.Owner.Value
local ThumbType = Enum.ThumbnailType.HeadShot
local ThumbSize = Enum.ThumbnailSize.Size100x100
script.Parent.Parent.Parent.Parent.Owner:GetPropertyChangedSignal("Value"):Connect(function()
if Owner ~= nil then
local Player = Players:FindFirstChild(Owner)
local UserId = Player.UserId
print(UserId)
local content = Players:GetUserThumbnailAsync(UserId, ThumbType, ThumbSize)
ImageLabel.Image = content
else
ImageLabel.Image = "rbxasset://textures/ui/GuiImagePlaceholder.png"
end
end)
this is in a server script and does not output a warning/error or print.
Have you verified that GetPropertyChangedSignal is firing? If you are not receiving any information, it is likely due to the property not firing.
I am unable to tell what Owner is but in my test with the script below. I am able to successfully update the ImageLabel.
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local content = Players:GetUserThumbnailAsync(Player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)
script.Parent.ImageLabel.Image = content
The structure for this is:
StarterGui
ScreenGui
LocalScript
ImageLabel
Result:
Side note: Please start a new topic. This will ensure that you get assistance related to your issue or question.
local Owner = script.Parent.Parent.Parent.Parenet.Owner
and change if Owner ~= nil then to if Owner.Value ~= nil then
same to local Player = Players:FindFirstChild(Owner) to local Player = Players:FindFirstChild(Owner.Value)
depends, if it’s on the screen(and you only have to see yours) you can just do it like this:
you can create the image label for everyone on the side of the screen, insert a localscript with this inside of it:
local userId = game:GetService("Players").LocalPlayer.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
script.Parent.Image = game:GetService("Players"):GetUserThumbnailAsync(userId, thumbType, thumbSize)