Hello there! It’s me again, I need help on how to make an NPC copy the local players looks, (meaning the player playing rn) I’ve searched the whole DevForum but still can’t find anything.
Here’s whats in the NPC (pretty obvious cuz he’s just a rig)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local description = humanoid:WaitForChild("HumanoidDescription")
local npc = workspace:WaitForChild("NPCstats")
local npcHumanoid = npc:WaitForChild("Humanoid")
local clone = description:Clone()
npcHumanoid:ApplyDescription(clone)
StarterPlayerScripts if you only want it to execute when the local player first joins, StarterCharacterScripts if it should execute each time the player’s character model reloads (spawns).
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local description = humanoid:WaitForChild("HumanoidDescription")
local npc = workspace:WaitForChild("NPCstats")
local npcHumanoid = npc:WaitForChild("Humanoid")
npcHumanoid:ApplyDescription(description)
Also I was cloning the description before (which isn’t really necessary) you can just use the character’s description directly instead.
If you want it so if a player joins, it copies the player’s avatar and puts it into the dummy
Use a server script
Put it in serverscriptservice
Put this in:
local players = game:GetService("Players")
local npc = -- PUT NPC HERE
players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(chr)
npc:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(plr.UserId))
for i, a in pairs(npc.Parent:GetChildren()) do
if a:IsA("CharacterMesh") then
a:Destroy()
end
end
end)
end)
`local npc = game.Workspace:FindFirstChild("YOUR_NPC_NAME")`
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
repeat wait()
char.Archivable = true
local clone = char:Clone()
for _, i in pairs(clone:GetDescendants()) do
if i:IsA("MeshPart") then
i.Anchored = true
i.Position = npc:FindFirstChild(i.Name).Position
i.Orientation = npc:FindFirstChild(i.Name).Orientation
end
if i:IsA("Part") then
i.Anchored = true
i.Position = npc:FindFirstChild(i.Name).Position
i.Orientation = npc:FindFirstChild(i.Name).Orientation
end
end
char.Archivable = false
clone.Parent = npc
until game:IsLoaded()
-- localscript in StarterPack`Preformatted text`
You can easily clone a player by using CreateHumanoidModelFromUserId.
The following will create a clone of every player who joins the game:
local Players= game:GetService("Players")
local spawnPos = 0
local function cloneCharacter(playerID, playerName)
local clonePlayer = Players:CreateHumanoidModelFromUserId(playerID)
clonePlayer.Name = playerName
local newPosX = clonePlayer.PrimaryPart.Position.X + spawnPos
clonePlayer.PrimaryPart.Position = Vector3.new(newPosX, 6, 0)
clonePlayer.Parent = workspace
spawnPos += 5
end
Players.PlayerAdded:Connect(function(player)
local player = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):wait()
cloneCharacter(player.userId, player.Name)
end)
Put the above into a script in ServerScriptService.