How's this GetUserThumbnailAsync not working?

I have a SurfaceGui with an image that should update to a player’s thumbnail image when an event is fired. However, this often doesn’t work and the image doesn’t update. I can confirm the event is being fired.

Code:

local rs = game:GetService("ReplicatedStorage")
local rm = rs:WaitForChild("Remotes")
local remote = rm:WaitForChild("WinnerImage")

remote.OnClientEvent:Connect(function(id,plr)
	print("Connected")
	local userId = id
	local thumbType = Enum.ThumbnailType.HeadShot
	local thumbSize = Enum.ThumbnailSize.Size420x420
	local content, isReady = game:GetService("Players"):GetUserThumbnailAsync(userId, thumbType, thumbSize)
	--game.Workspace.Lobby.LastWinner.UI.SurfaceGui.ImageLabel.Image = nil
	wait(1)
	--isReady = true
	game.Workspace.Lobby.LastWinner.UI.SurfaceGui.ImageLabel.Image = content
	print("set")
end)
2 Likes

Try: remote.OnClientEvent:Connect(function(plr, id)

1 Like

How could that change anything?

1 Like

“plr” is player, the first variable declared on the function “onclientevent”

1 Like

It’s not changing anything? Isn’t it just swapping the variable order? Only .OnServerEvent has the built-in argument “player”. (I think)

1 Like

Try:

local rs = game:GetService("ReplicatedStorage")
local rm = rs:WaitForChild("Remotes")
local remote = rm:WaitForChild("WinnerImage")

remote.OnClientEvent:Connect(function(plr)
	print("Connected")
	local userId = plr.UserId
	local thumbType = Enum.ThumbnailType.HeadShot
	local thumbSize = Enum.ThumbnailSize.Size420x420
	local content, isReady

local success, erMSG = pcall(function()
content, isReady = game:GetService("Players"):GetUserThumbnailAsync(userId, thumbType, thumbSize)
end)

	--Workspace.Lobby.LastWinner.UI.SurfaceGui.ImageLabel.Image = nil
	wait(1)
	--isReady = true
	game.Workspace.Lobby.LastWinner.UI.SurfaceGui.ImageLabel.Image = content
	print("set")
end)

I’m not sure why yo would pass the UserId through the client, just use plr.UserId

1 Like

Are there any errors in the Output window? If so, please share them.

1 Like

Nope, nothing. Let me try his solution again.

1 Like

@COUNTYL1MITS @ItsPlasmaRBLX
No errors, and not working.

1 Like

Where in the game explorer is this script located?

1 Like

I’m not sure what you’re doing wrong, the script seems to be working perfectly fine with me. Make sure it’s a server script, in ServerScriptService or Workspace.

image

local __thumbnail = game:GetService("Players"):GetUserThumbnailAsync(1, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420);

3 Likes

Huh. Saw somewhere that it should be on a LocalScript. Let me try to put it on the server.

1 Like

No, the event “onclientevent” is on the server. Make sure your code is located on the Server!

What? OnClientEvent is recieved by the server.

Can I see the corresponding FireClient() or FireAllClients() function call?

Yes, OnClientEvent is on the server, fired by a client.


:arrow_double_up: :arrow_double_up: :arrow_double_up:

https://developer.roblox.com/en-us/api-reference/event/RemoteEvent/OnClientEvent

@ItsPlasmaRBLX it states that “To listen for a message on the client, a LocalScript needs to connect a function to the OnClientEVent”

@Limited_Unique Alright, give me a moment. I’m gonna try another solution.

Clients CANNOT communicate with each other like this, this is done on the server. I’m loosing braincells over this, this should not be an 17+ reply chain.

Huh? The server is firing the event that the LocalScript receives…

Worked on the server once, let me conduct a couple more tests to see if it’s solid.