My Image on ImageLabel won't change!

The objective is to change the Image on the ImageLabel to the avatar icon of the player which is on the Winner StringValue, i am doing this by storing the ID from the player who touched the part in a StringValue and then using it this way:

script.Parent.Image = "https://www.roblox.com/headshot-thumbnail/image?width=420&height=420&format=png&userId="..plrID

But when i load the game and touch the part, it only changes the Name of the player who touched it but not the Image at all:

image

1 Like

I want to see the entire script or I can’t figure out what’s happening on your script.

local value = game.ReplicatedStorage.vals.Winner
local plrID = game.ReplicatedStorage.vals.Winner.WinnerID.Value
local Icon = script.Parent.Parent

value:GetPropertyChangedSignal("Value"):Connect(function()
if value.Value ~= "" then
	script.Parent.Parent.Text = value.Value
	script.Parent.Image = "https://www.roblox.com/headshot-thumbnail/image?width=420&height=420&format=png&userId="..plrID
	Icon:TweenPosition(UDim2.new(0.739, 0, 0.407, 0))
    elseif value.Value == "" then
	Icon:TweenPosition(UDim2.new(1, 0,0.407, 0))
	script.Parent.Parent.Text = ""
	script.Parent.Image = ""
end
end)

Try GetUserThumbnailAsync. I think it is better way to get player image.

local Players = game:GetService("Players")
local content, isReady = Players:GetUserThumbnailAsync(plrID, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
script.Parent.Image = content

More information from here.

1 Like

I don’t know if i replaced it right but i am getting this on the output:

image

It leads to this line of code:

local content, isReady = Players:GetUserThumbnailAsync(plrID, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)

Are you sure that plrID is the winners UserID? because I did some testing and this code

local Players = game:GetService("Players")
local content, isReady = Players:GetUserThumbnailAsync("awdaw", Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)

Made the same error

My guess is that you are using a text(string, letters) instead of numbers.

1 Like

Would you be able to do

print(plrID)

for us and show us the output? This may help us solve the issue.

1 Like

I printed it and it is returning absolute nothing:

image

I don’t get why since i verified lots of times and i am 100% sure that plrID is getting the ID stored in the stringvalue

Do you mean on touch it appears the player icon that touched the part?

1 Like

What i am doing is:

  • The player touches the part
  • The part stores the Name and ID of the player who touched it into the Winner stringvalues
  • The current script that i posted here detects when the Winner Value changed and update the Text and ImageLabel to the player’s

The part even returns the Name and ID of the player who touched it in the output, but when i try with the changed value script it doesn’t return anything:

image

Instead of using

You could alternatively use a remote event to fire the values to all clients ( since I’m assuming you’re using GUIs to display the winner) and from the fired tuple arguments, use the ID you sent over to the client.

This way, you know what is being sent and it is a lot easier to guess and check with different values.

If you need help with this let me know, or if you want to continue with :GetPropertyChangedSignal() thats all good too, I’ve just never really used it before so I don’t quite know the outputs of it.

1 Like

I really appreciate all your help guys but i found the solution, i just needed to add a Wait(value.Value) ._.

image

Now it works:

image

1 Like

well tonumber(plrID) will fixing them.
ok so congrats