You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? To apply a humanoid description to the npc
-
What is the issue? When trying to apply humanoid description, the error “attempt to index nil with userid” pops up.
local Players = game:GetService("Players")
local function getPlayersArray()
local players = {}
for _, p in pairs(Players:GetPlayers()) do
local points = p.leaderstats.Kills --change this to the points location
table.insert(players, {player = p, Points = points})
end
return players
end
local players = getPlayersArray()
table.sort(players, function(a, b)
return a.Points > b.Points
end)
local third = Players:GetHumanoidDescriptionFromUserId(players[3].UserId)
workspace["3rdPlaceDummy"].Humanoid:ApplyDescription(third)
local second = Players:GetHumanoidDescriptionFromUserId(players[2].UserId)
workspace["2ndPlaceDummy"].Humanoid:ApplyDescription(second)
local first = Players:GetHumanoidDescriptionFromUserId(players[1].UserId)
workspace["1stPlaceDummy"].Humanoid:ApplyDescription(first)