How To Make NPC Look Like Local Player

Try this.

local Oldhumanoid = game.Workspace:FindFirstChild("DancingRig").Humanoid --Replace with pathway to Humanoid of the NPC. 
local localPlayer = game.Players.LocalPlayer
local function applyAppearance()
	local humanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(localPlayer.UserId)
	task.wait(0.5)

	local Newhumanoid = Oldhumanoid:Clone()
	Newhumanoid.Parent = game.Workspace:FindFirstChild("DancingRig")
	Oldhumanoid:Destroy()
	Newhumanoid:ApplyDescription(humanoidDescription)
end

applyAppearance()
4 Likes

yup now it looks exactly like me when i join i just got to make it so that it looks like local player thats looking at it

im gonna do a test right now in a normal server to see if the rig looks like me when i join and looks like the other player when they join

yup it works you did it when i join on my alt it looks like them for them and when i join it looks like me for me

you can save a player’s character to repstorage on join.
have a part in repstorage named “DancePosition” and position it and rotate it for the new rig to be spawned in

Serverscript in ServerScriptService:

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local newchar = character:Clone()
newchar.Parent = game:GetService("ReplicatedStorage")
local animation = Instance.new("Animation", newchar)
animation.Name = "Dance"
animation.AnimationId = (animid)

newchar:PivotTo(game:GetService("ReplicatedStorage").DancePosition.CFrame

for _, v in pairs(newchar:GetDescendants()) do
if v:IsA("BaseScript") then
v:Destroy()
end
end
end)
end)

game.Players.PlayerRemoving:Connect(function(player)
game:GetService("ReplicatedStorage"):FindFirstChild(player.Name):Destroy()
end)

Localscript in StarterCharacterScripts

local player = game.Players.LocalPlayer
local character = game:GetService("ReplicatedStorage"):FindFirstChild(player.Name)

function loadchar()
character.Parent = workspace
character.Humanoid:LoadAnimation(character.Dance):Play()
end

loadchar()

make sure that you set parent back to repstorage when finished the scene

This will cause all clients to run this animation, which is not recommended. As animations are related to the humanoid Animator creation by the server

Instead, if you use the method that I have with a dance animation and do:

local Oldhumanoid = game.Workspace:FindFirstChild("DancingRig").Humanoid --Replace with pathway to Humanoid of the NPC. 
local localPlayer = game.Players.LocalPlayer
local Animation = nil -- Put animation path here 
local function applyAppearance()
	local humanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(localPlayer.UserId)
	task.wait(0.5)

	local Newhumanoid = Oldhumanoid:Clone()
	Newhumanoid.Parent = game.Workspace:FindFirstChild("DancingRig")
	Oldhumanoid:Destroy()
    if Newhumanoid:FindFirstChild("Animator") then
      Newhumanoid:FindFirstChild("Animator"):Destroy()
    end
    local Animator = Instance.new("Animator", Newhumanoid)
	Newhumanoid:ApplyDescription(humanoidDescription)
    Newhumanoid:LoadAnimation(Animation):Play()
end

applyAppearance()

That will make it run on the client only, because of a new client ran humanoid Animator

Edited using new animator

1 Like

according to this

that is not the case

(maybe because I read it idk)

Sorry, Animation Controller.

Still won’t work. Here is one of my posts where I learned animations are replicated to the server based on the animation controller as seen here. the same is applied with the deprecation of loading animations with humanoid

In order to make local animations, the animator must be destroyed and remade on the client. Because by default they will replicate to the server

you can save a player’s character to repstorage on join.
have a part in repstorage named “DancePosition” and position it and rotate it for the new rig to be spawned in

Serverscript in ServerScriptService:

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local newchar = character:Clone()
newchar.Parent = game:GetService("ReplicatedStorage")
local animation = Instance.new("Animation", newchar)
animation.Name = "Dance"
animation.AnimationId = (animid)

newchar:PivotTo(game:GetService("ReplicatedStorage").DancePosition.CFrame

for _, v in pairs(newchar:GetDescendants()) do
if v:IsA("BaseScript") then
v:Destroy()
end
end
end)
end)

game.Players.PlayerRemoving:Connect(function(player)
game:GetService("ReplicatedStorage"):FindFirstChild(player.Name):Destroy()
end)

Localscript in StarterCharacterScripts

local player = game.Players.LocalPlayer
local character = game:GetService("ReplicatedStorage"):FindFirstChild(player.Name)

function loadchar()
character.Parent = workspace
if character.Humanoid:FindFirstChild("Animator") then
character.Humanoid.Animator:Destroy()
end
Instance.new("Animator", character.Humanoid)
character.Humanoid:LoadAnimation(character.Dance):Play()
end

loadchar()

make sure that you set parent back to repstorage when finished the scene

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.