I am making a script for a game in ROBLOX that I am working on that requires the player's thumbnail image to be shown on a GUI grid. I need to do this by getting the players UserId, but there is an error.
Script:
local PlayersFrame = script.Parent:WaitForChild("PlayersFrame")
local rStorage = game:GetService("ReplicatedStorage")
local rEvents = rStorage:WaitForChild("RemoteEvents")
local plr = game.Players.LocalPlayer
rEvents.AddPlayer.OnClientEvent:Connect(function(plr)
local image = Instance.new("ImageLabel",PlayersFrame)
image.Name = plr.UserId
image.BorderSizePixel = 0
image.BackgroundTransparency = .65
image.BackgroundColor3 = Color3.fromRGB(0,0,0)
image.Image = game.Players:GetUserThumbnailAsync(plr.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420
end)
The error is, "Attempt to index nil with 'UserId'" and it is on line 3 and 7 shown above. If someone knows how to fix this please comment.

1 comment
Thank you so much DevingDev, this worked!