Hello. I’m adding an “Employee of the month” poster to my game. The way it works is that it iterates through the players and gets an IntValue that the player is a parent of and saves the player with the highest value of that IntValue. Then the script applies the player name into the ImageLabel and TextLabel. Issue is that for some reason it doesn’t apply the properties because of an error.
local Players = game:GetService("Players")
local ImageLabel = script.Parent
local PlayerName = script.Parent.Parent.PlayerName
local function ReturnEmployeeOfTheMonth()
local playerTable = {}
for i, player in ipairs(Players:GetPlayers()) do
table.insert(playerTable, {
player.Name,
player.BrickCount.BrickCountValue.Value
})
end
table.sort(playerTable, function(a, b)
return a[2] > b[2]
end)
return playerTable[1]
end
local function onPlayerAdded(player)
local intValue = player.BrickCount.BrickCountValue
intValue.Changed:Connect(function()
local employeeOfTheMonth = ReturnEmployeeOfTheMonth()
print(employeeOfTheMonth)
end)
end
Players.PlayerAdded:Connect(onPlayerAdded)
while true do
task.wait(10)
local employeeOfTheMonthData = ReturnEmployeeOfTheMonth()
if not employeeOfTheMonthData then
continue;
end
local id = employeeOfTheMonthData[1]
local ThumbType = Enum.ThumbnailType.HeadShot
local ThumbSize = Enum.ThumbnailSize.Size150x150
local plrAvatar, isReady = Players:GetUserThumbnailAsync(id, ThumbType, ThumbSize)
ImageLabel.Image = plrAvatar
PlayerName.Text = employeeOfTheMonthData[1]
print(employeeOfTheMonthData[1])
print(employeeOfTheMonthData[2])
end
local employeeOfTheMonth = ReturnEmployeeOfTheMonth()
print (employeeOfTheMonth)
Any and all help is greatly appreciated.