I'm facing an issue where in a server script I am executing this code:
local assetsUtils = require(game.ServerStorage.Utils.AssetsManager)
local Players = game:GetService("Players")
-- When a player joins, fetch thumbnail.
Players.PlayerAdded:Connect(function(player)
assetsUtils.getPlayerThumbnail(player)
end)
I have a module script named AssetsManager with the following function inside:
local AssetsManager = {}
function AssetsManager:getPlayerThumbnail(player)
print(player)
-- Get Player Thumbnail
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size150x150
local content = player:GetUserThumbnailAsync(userId, thumbType, thumbSize)
-- Set Image Label to Thumbnail
local playerThumbnail = Instance.new("ImageLabel")
playerThumbnail.Name = userId
playerThumbnail.Parent = game.ReplicatedStorage.PlayerThumbnails
print("Thumbnail for " .. userId .. "fetched.")
end
return AssetsManager
When I run the server script and print the value of player it is nil despite me passing the player parameter to the function. Does anyone know why this is happening and what I could do to fix it?
Thank you!
