Hi, I am trying to loop through a model’s children, clone them, and add them into a new model instance.
Unfortunately, only a few of the children get parented to the new Model. Here is my code:
local event = game.ReplicatedStorage.RemoteEvents.MorphPlayer
event.OnServerEvent:Connect(function(player, character)
local characterFolder = game.ReplicatedStorage.Characters:WaitForChild(character)
local characterModel = characterFolder:WaitForChild(character)
local playerCharacter = player.Character or player.CharacterAdded:Wait()
local clonedCharacterModel = Instance.new("Model")
clonedCharacterModel.Name = characterModel.Name
for i, v in pairs(characterModel:children()) do
print(v.Archivable)
local clonedValue = v:Clone()
if clonedValue.Name == "HumanoidRootPart" then
clonedCharacterModel.PrimaryPart = clonedValue
end
clonedValue.Parent = clonedCharacterModel
end
clonedCharacterModel.PrimaryPart.CFrame = playerCharacter.HumanoidRootPart.CFrame
clonedCharacterModel.Name = playerCharacter.Name
player.Character = clonedCharacterModel
clonedCharacterModel.Parent = workspace
end)