Cloning Player's Character

I am not able to alter size and CFrame of clonedCharacter.

Here’s the script:

local function ClonePlayer()
	for _, player in pairs(game:GetService("Players"):GetPlayers()) do
		if table.find(Table_Win, player.Name) == 1 then
			local character = player.Character or player.CharacterAdded:Wait()
			if character then
				character.Archivable = true
				local clonedCharacter = character:Clone()
				clonedCharacter.Archivable = false
				clonedCharacter.Parent = workspace
				clonedCharacter.PrimaryPart.Size = Vector3.new(43.422, 43.422, 43.422)
				local scaleFactor = 100
				for _, part in pairs(clonedCharacter:GetChildren()) do
					if part:IsA("BasePart") or part:IsA("MeshPart") or part:IsA("Part") then
						part.Size = part.Size * scaleFactor
					end
				end
				clonedCharacter.PrimaryPart:PivotTo(CFrame.new(-54.027, 115.786, -112.663))
			end
		end
	end
end

This is the output I am getting :

What I’ve noticed is that if I change size of all Character parts in the iterating for loop to desired Vector3.new(43.422, 43.422, 43.422), it will alter the position as well and cause deformation in Cloned object. Another thing I’ve noticed is that if each part position in the for loop is changed to CFrame.new(-54.027, 115.786, -112.663)), it will make the Cloned object look like a square shape.

You can’t scale a model by changing the size of each child. Try using Model:ScaleTo()

1 Like

Fortunately I have a module that scales characters.

return function(character:Model, scale:number)
	assert(character and character:IsA("Model"), `Model expected for character, got {typeof(character)}`)
	assert(scale and typeof(scale) == "number", `Number expected for scale, got {typeof(scale)}`)
	
	--// Rescaling character
	local kCharacterScale = character:GetAttribute("KCharacterScale")
	local diff = scale / (kCharacterScale or 1)

	for _, v in character:GetDescendants() do
		if v:IsA("BasePart") then
			v.Size *= diff
		elseif v:IsA("JointInstance") then
			v.C0 -= v.C0.Position * (1 - diff)
			v.C1 -= v.C1.Position * (1 - diff)
		elseif v:IsA("SpecialMesh") and v.MeshType == Enum.MeshType.FileMesh then
			v.Scale *= diff
		end
	end
end

The scale is basically the percentage of how much bigger/smaller you want the character to be, with 1 being 100% (no change). So if you want the character to double in size you put 2.

If that doesn’t work, then there’s an issue with cloning the character.

1 Like

Fixed the issue when I saw instances inside of Humanoid which hold values for scales
The inserted code snippet :

clonedCharacter:FindFirstChild("Humanoid").BodyHeightScale.Value = scaleFactor
clonedCharacter:FindFirstChild("Humanoid").BodyWidthScale.Value = scaleFactor
clonedCharacter:FindFirstChild("Humanoid").BodyDepthScale.Value = scaleFactor
clonedCharacter:FindFirstChild("Humanoid").HeadScale.Value = scaleFactor

Looks complicated for a easy function but thanks for the module. Hope it helps the others as well !

Interesting function that I’ve learnt today. Thanks for the idea !