How do I make it so the avatar of my NPC changes when I change my avatar on Roblox?

What I’m trying to achieve:
I want my NPC’s avatar in game to change when I change my avatar on Roblox.

What is the issue?
I used AlreadyPro’s load character plugin to import my NPC, I recently changed my avatar on Roblox, but when I joined my game my NPC still has my old avatar.
Screenshot: https://media.discordapp.net/attachments/707492466072223794/733601912510873620/unknown.png

Solutions I’ve tried so far:
I haven’t really tried anything to fix it since I have no idea what to do. I tried looking for answers on YouTube, Roblox wiki, and the developer forum, but I couldn’t find any solutions for my problem.

I’m not really good at scripting so I’m not really sure on what to do. Help would be appreciated, Thanks. :slight_smile:

12 Likes

If you use AlreadyPro’s plugin to load your character in Studio, it will never change since they are the actual parts and clothing that your avatar was wearing at the given time. If you want to have your game update every time you change your avatar, you should make use of GetCharacterAppearanceAsync() to load the model in yourself every time the game starts up. So an example for your ID would be:

local GirlSwag911Model = game.Players:GetCharacterAppearanceAsync(117777231)
GirlSwag911Model.Torso.CFrame = Vector3.new() --The location of your model.
GirlSwag911Model.Parent = game.Workspace

That would be all I guess. :smile:

7 Likes

Can you explain to me on how to do this step by step? I don’t really understand, Sorry.

1 Like

Sure! So let’s just say you wanted to place your model at position A. If you wanted to make it simple, just place a part where you want your model to be. Place it in workspace, and name it positionA. Then, your script would be:

local positionA = workspace.positionA.Position --This would store the desired location into this variable.
local model = game.Players:GetCharacterAppearanceAsync(117777231) -- Gets your Roblox avatar load-out.
model.Parent = workspace --Adds it to Workspace, which is the basically the visible world of your game.
1 Like

I did that but this happened: https://media.discordapp.net/attachments/707492466072223794/733633835446566932/unknown.png I’m not sure what I did wrong.

Could I see your full script please?

I tried the code myself - you are right, sorry. The model is spawned but it is all out of orientation. I will try to find a way to apply all the appropriate properties to them to have it intact. As of now, I have this to anchor the parts:

local positionA = workspace.positionA
local model = game.Players:GetCharacterAppearanceAsync(117777231)
for i,v in pairs(model:GetDescendants()) do
	print(v.Name)
	if v:IsA("Part") or v:IsA("MeshPart") then
		v.Anchored = true
	end
end
model.Parent = workspace

I will let you know if I find anything. :slightly_smiling_face:

That worked but the problem is there are still weird parts that spawn, it doesn’t have a head, and it doesn’t look like my avatar on Roblox. I appreciate the help though. :slight_smile:

1 Like

Yep sorry for not being able to help much. I am getting closer though, I found a better way to do it. If you’re free you could experiment around with this I guess. So I set up a folder and model with all the default parts:
image
Then when the game starts, the script would get data using GetCharacterAppearanceAsync() and add it to the model:
image
It seems to be going well, I think this is along the lines of what should be done. It’s not complete though, but if you have time you could try play around with it. When I’m free I’ll also try to finish it up since I’m pretty interested too. :smiley:

Add-on to the previous post:

local CharacterModel = workspace.CharacterModel
local CharacterParts = game.Players:GetCharacterAppearanceAsync(117777231)
for i,v in pairs(CharacterParts:GetDescendants()) do
	print(v.Name)
	if v:IsA("Part") or v:IsA("MeshPart") then
		v.Anchored = true
	elseif v:IsA("Accessory") then
		CharacterModel.Humanoid:AddAccessory(v)
	end
end

This was the script I used.

Personally I’d use the HumanoidDescription system as it’s way easier and you don’t have to worry about accessories separately to clothes, separately to packages, etc. You just need a humanoid in a blank rig and call Humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(117777231))

Where 117777231 is the user ID of the player you want it to match - in this case, yours.

3 Likes

Oh that worked. Thanks for saving me (possibly) a few hours of my life!!

No worries. There’s a :white_check_mark: Solution button if that solved your topic to help others skip straight to the answer if they come across this thread.

Oh I’m not the topic creator haha sorry - I was just trying to help but found this problem interesting so I wanted to find a way to solve it, but hopefully @GirlSwag911 will do that when she sees it. Very clear explanation by the way, thank you once again.

1 Like

This is a dumb question but where do I put Humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(117777231))?

In a script, possibly just in ServerScriptService. If you have just one avatar in the Workspace and it has a unique name,

game.Workspace.YourNPCModelName.Humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(117777231))

You could get a bit fancier, but at the absolute minimum that should solve your problem. It will apply your avatar design to the NPC model each time the game server loads to play the game.

16 Likes

Thank you! It worked. :slight_smile: