I am currently working on a load character plugin, and i used a dummy model for the inserting. But when you use the plugin the player’s (that you spawn in) arms,legs,head, etc is not the player’s avatar arms,legs,head,etc.
The following is the script:
script.Parent.MouseButton1Click:Connect(function()
local Players = game:GetService("Players")
local name = script.Parent.Parent.NameBox.Text
local cache = {}
local function getUserIdFromUsername(name)
if cache[name] then return cache[name] end
local player = Players:FindFirstChild(name)
if player then
cache[name] = player.UserId
return player.UserId
end
local id
pcall(function ()
id = Players:GetUserIdFromNameAsync(name)
end)
cache[name] = id
return id
end
local realname = getUserIdFromUsername(name)
local dummy = script.Parent.Parent.R15:Clone()
local newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(realname)
dummy.Parent = workspace
local function getUsernameFromUserId(userId)
if cache[userId] then return cache[userId] end
local player = Players:GetPlayerByUserId(userId)
if player then
cache[userId] = player.Name
return player.Name
end
local name
pcall(function ()
name = Players:GetNameFromUserIdAsync(userId)
end)
cache[userId] = name
return name
end
local idfromplayer = getUsernameFromUserId(realname)
dummy.Name = idfromplayer
dummy.Humanoid:ApplyDescription(newHumanoidDescription)
end)
If you know how to fix this, please say so in the replies!
// I have these functions:
function GetUserId(Name)
local UserId
local success, response = pcall(function()
UserId = game.Players:GetUserIdFromNameAsync(Name)
end)
if success then
print(UserId)
return UserId
end
end
function GetAvatarImage(UserId)
local ThumbnailType = Enum.ThumbnailType.HeadShot
local ThumbnailSize = Enum.ThumbnailSize.Size420x420
local Content
local Success, Response = pcall(function()
Content = game.Players:GetUserThumbnailAsync(UserId, ThumbnailType, ThumbnailSize)
end)
if Success then
return Content
end
end
function GetHumanoidDescription(UserId)
local HumanoidDescription
local success, response = pcall(function()
HumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(UserId)
end)
if success then
return HumanoidDescription
end
end
function ApplyHumanoidDescription(HumanoidDescription, UserId)
local Avatar = Dummy:Clone()
Avatar.Parent = workspace
Avatar.Name = game.Players:GetNameFromUserIdAsync(UserId)
Avatar.Humanoid:ApplyDescription(HumanoidDescription)
end
Then:
When the player presses the button in the plugin:
local PlayerName = NameBox.Text -- the text box
if PlayerName ~= "" then
local UserId = GetUserId(PlayerName)
local HumanoidDescription = GetHumanoidDescription(UserId)
ApplyHumanoidDescription(HumanoidDescription, UserId)
end
Something important to note is that if the player doesn’t exist it will error, but you can just add some if statements to prevent that