How to load the player character into an NPC locally?

Hello!
For my main menu, I wanted to load the local player character into an NPC, and make it only locally.
I used the basic script using :GetHumanoidDescription, but it said that I could only use it in server. Then I tried a method using RemoteEvent like this :

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAppearanceLoaded:Connect(function(char)
		game.ReplicatedStorage.ReplaceDummy:FireClient(plr, char)
	end)
end)

and this

game.ReplicatedStorage.ReplaceDummy.OnClientEvent:Connect(function(plr)
	plr.HumanoidRootPart.CFrame = game.Workspace.Dummy.HumanoidRootPart.CFrame
	plr.Parent = workspace
end)

But the plr variable returns “nil”.
Can someone help me please?

You could probably use the :GetCharacterAppearanceAsync(player) method to return a list of items the player is currently wearing, then locally add them to the NPC.

https://developer.roblox.com/en-us/api-reference/function/Players/GetCharacterAppearanceAsync

3 Likes

I’ll try that and i’ll provide news, Thanks for the idea

Okay so, I managed to load the appearance into a dummy, but the accessories does not stick to the dummy.

Edit : When I cloned my R15 avatar that I pasted in the baseplate, it worked, but when I did the same with R6, it failed. How can I fix it?

What is the NPC’s humanoid’s rig type? R6 or R15?

This is how you should apply a player’s character’s appearance to an NPC model.

local players = game:GetService("Players")

local npc = workspace.Dummy
local npcHuman = npc.Humanoid

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if not player:HasAppearanceLoaded() then
			player.CharacterAppearanceLoaded:Wait()
		end
		
		local human = character:WaitForChild("Humanoid")
		local description = human:GetAppliedDescription()
		npcHuman:ApplyDescription(description)
	end)
end)

This is working for me with both avatar types (R6 and R15).

8 Likes