Hello, I have a problem with the positioning of the R15 dummy in the viewport frame.
It is designed to replicate the humanoid description (e.g. accessories and appearance). I figured out that in order to attach accessories to the dummy, you have to first parent it to the workspace, apply the description and parent it back to the viewport frame. But the problem is that it always rotates in a weird way.
I have tried everything, but nothing has worked. I would be glad if you could help me find the problem. Here is my code with my attempts to fix it:
local function ApplyNewDesc(username, template:Model)
local UserId = game.Players:FindFirstChild(username).UserId
local HumanoidDescription
local success,err = pcall(function()
HumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(UserId)
end)
if success then
local PrevLocation = template.Parent
template.Parent = workspace
template.PrimaryPart.CFrame = CFrame.new(Vector3.new(0, 0, 0))
print(template:GetPivot())
template.Humanoid:ApplyDescription(HumanoidDescription)
task.wait(0.1)
template.Parent = PrevLocation
template.PrimaryPart.CFrame = CFrame.new(Vector3.new(0, 0, 0))
else
task.wait()
ApplyNewDesc(username, template)
end
end
okay, instead of parenting it at workspace and back to viewport, best you use - Players:CreateHumanoidModelFromUserId(player.UserId) as still it gets the players accessories.
this is a server script btw
-- //Services
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player: Player)
-- //Character
local character = player.Character or player.CharacterAdded:Wait()
-- //Humanoid
local Humanoid = character:FindFirstChild("Humanoid")
local HumanoidDescription = Humanoid:FindFirstChild("HumanoidDescription")
-- //
local newCharacter
local success, errorMessage = pcall(function(...)
newCharacter = Players:CreateHumanoidModelFromDescription(HumanoidDescription, Enum.HumanoidRigType.R15) -- //change the R15 to R6 if you like, this is diff from userId
end)
if success then
newCharacter.Parent = workspace
else
warn(errorMessage)
end
end)