I am having problems with loading character into a dummy. I want it to load it locally, so the dummy looks like their avatar in-game, but I can’t figure out how!
HumanoidDescriptions can be used to apply clothes, and other items to characters:
https://developer.roblox.com/en-us/api-reference/class/HumanoidDescription
These pages can help you to do it:
https://developer.roblox.com/en-us/api-reference/function/Players/GetHumanoidDescriptionFromUserId
https://developer.roblox.com/en-us/api-reference/function/Humanoid/ApplyDescription
A little help? (The script is in StarterCharacterScripts)
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local plrId = Player.UserId
local Avatar = PlayerService:GetHumanoidDescriptionFromUserId(plrId)
game.Workspace.Dummy.Humanoid:ApplyDescription(Avatar)
What is the problem that you’re currently experiencing?
So a player joins, and I want a dummy to be replaced by their avatar, only for them though!
So if I understand correctly, the dummy already exists before the player joins. You just want to hotswap an existing Dummy character and load it for the incoming player?
Are you unable to set Player.Character
to the Dummy
and then like others have mentioned use Humanoid:ApplyDescription
after some custom PlayerAssumedCharacter
event?
My code is basically in StarterCharacterScripts.
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local plrId = Player.UserId
local Avatar = PlayerService:GetHumanoidDescriptionFromUserId(plrId)
game.Workspace.Dummy.Humanoid:ApplyDescription(Avatar)
This would stop working when:
- There’re no Dummy characters left in the workspace.
- The specific Dummy character the script found during the index of game.Workspace.Dummy no longer exist.
Do you have any code that’s creating more Dummy characters? Are there separate code for indexing Dummy character’s outside of game.Workspace.Dummy
. E.g workspace:FindFirstChild(“Dummy”) or
some code that clones the Dummy to the workspace?
Or are you just placing a single Dummy in the workspace and testing if you can change the appearance one time?
I am placing a single dummy to test if it changes appearance.
That’s the correct code, did it not work?
Not sure, it says Something about Server Side Backend.
HumanoidDescriptions cannot be applied on the client with a existing humanoid, btw.
You need to create the humanoid in the script and parent it to the dummy. THEN apply it.
Example:
local UI = script.Parent
local TextButton = UI:WaitForChild('TextButton')
local Dummy = workspace:WaitForChild('Dummy')
TextButton.MouseButton1Down:Connect(function()
Dummy.Humanoid:Destroy()
local NewHumanoid = Instance.new("Humanoid",Dummy)-- get mad
NewHumanoid:ApplyDescription(game.Players.LocalPlayer.Character.Humanoid:GetAppliedDescription())
end)