CFrame replication issues when rapidly changing the CFrame of multiple objects

Hello, I’ve made myself a ‘morph module’ to make the application of a morph onto my players a lot easier for myself. The issue I’m having is that when it goes to actually apply the morphs, which is does limb by limb, it seems like the positions of the parts/meshparts/unions aren’t replicating correctly. The morph is applied serverside.

Code:

local function applyMorphLimb(characterMorphLimbFolder,playerCharacterLimb,morphLimbModel) -- Function used to apply individual morphs
	if not playerCharacterLimb or not morphLimbModel or not characterMorphLimbFolder then return end
	
	local replicatedLimbModel = morphLimbModel:Clone();
	local limbAnchorPart = replicatedLimbModel:FindFirstChild('Middle') or Instance.new('Part'); -- If an anchorPart doesn't already exist, then lets make one. Making one is LESS accurate!
	
	if not replicatedLimbModel:FindFirstChild('Middle') then -- Check if we need to set the size or not depending on if it already exists.
		limbAnchorPart.CFrame = replicatedLimbModel:GetModelCFrame();
		limbAnchorPart.Size = Vector3.new(0,0,0) 
	end
	
	limbAnchorPart.Name = 'Middle';
	limbAnchorPart.Transparency = 1;
	limbAnchorPart.Anchored = true;
	limbAnchorPart.Parent = replicatedLimbModel;
	
	replicatedLimbModel.Parent = workspace;
	replicatedLimbModel.PrimaryPart = limbAnchorPart;
	replicatedLimbModel:SetPrimaryPartCFrame(playerCharacterLimb.CFrame);
	
	local morphLimbChildren = replicatedLimbModel:GetChildren();
	
	for morphLimbPartNumberIndex,morphLimbPart in pairs(morphLimbChildren) do
		if morphLimbPart ~= limbAnchorPart then
			local morphWeld = Instance.new('WeldConstraint');
			morphWeld.Part0 = morphLimbPart;
			morphWeld.Part1 = playerCharacterLimb;
			morphWeld.Name = 'morphWeld';
			morphWeld.Parent = morphLimbPart;
			
			morphLimbPart.Anchored = false;
			morphLimbPart.CanCollide = false;
			
			morphLimbPart.Parent = characterMorphLimbFolder
		end
	end
	
	replicatedLimbModel:Destroy() -- All the items within the model have been moved into the character folder
end

Screenshots:

Local


Server

As you can see by the screenshots, the morph is messed up locally but is applied perfectly serverside.
Any and all help is appreciated!

1 Like

I know this isn’t directly answering your question but instead suggesting an alternative: it’s issues like this that lead me to just use accessories. I pre-weld everything in Studio or have a script do it at run time, then all I need to do is add the appropriate accessory to the character on request. Cleaner, less of a hassle and often always devoid of problems other than avatar resizing when done with multiple-part accessories.

2 Likes

Alright, I will definitely look into possibly using this method. Thanks!

Have you run into issues regarding updating a player’s appearance using something like Humanoid Description? Like if I were to add a morph to a player via appearances, have you encountered issues of it being removed when removing other accessories?