So, I have a sign that shows the last winner of the last round of my game. I have looked at multiple ways to get a player’s icon but it won’t work with the position my script is in and how I am getting the winner’s information.
I have a StringValue in replicated storage that is named “Winner”. That is how I am storing the player’s name and I have an object that they have to touch to win. The part adds a win to their ‘Wins’ leaderstat. So I have gotten the character but in the server script under the part. I don’t know if that is useful but I hope it is possible to get the player’s icon/face image.
Sign:
Explorer:
Edit: I tried doing it from the part that you touch itself. I keep getting errors about the UserId. Does anyone know how I would fix this?
Script:
local npc = script.Parent
local winner = game.ReplicatedStorage.Winner
local Players = game:GetService("Players")
local db = true
npc.Chicken.MeshPart.Touched:Connect(function(part)
if db == true then
db = false
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
player = game.Players:FindFirstChild(h.Parent.Name)
if (player~=nil) then
local stats = player:findFirstChild("leaderstats")
if (stats~=nil) then
local Score = stats:findFirstChild("Wins")
if (Score~=nil) then
Score.Value += 1
end
end
end
end
winner.Value = tostring(player)
-- 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)
game.Workspace.WinnerSign.Sign.SurfaceGui.PlayerPicture.Image = content
game.ReplicatedStorage.ChickenStatus = false
npc.Humanoid.Health = 0
task.wait(1)
npc:Destroy()
end
end)