Character position stops replicating after welding?

I’m making it so all characters are rendering locally by creating them locally and welding them to the actual player in workspace, but when I do this the position of the actual player stops replicating? I don’t understand, I’ve tried all the fixes I could think of, but nothing worked. Nothing in the model is anchored either.

https://i.gyazo.com/acbae099111818ea09067106d2c69477.gif

What is annoying me the most is that sometimes, but rarely sometimes it works perfectly fine! I don’t understand why?

Here is the local welded character

image

Here is the server-side character the local one welds to

image

The position starts replicating as soon as I remove the welded character

https://i.gyazo.com/4d1fb2e2cb1086f33bff57e4d77a41b1.gif

This is the code:

function createLocalCharacter()
	local lCharacter = replicatedStorage:WaitForChild("localCharacter"):Clone()
	lCharacter.Name = "localCharacter"
	lCharacter.Parent = game:GetService("Workspace")["Local Characters"]
	lCharacter.HumanoidRootPart.CFrame = rootPart.CFrame
	local weld = Instance.new("Weld")
	weld.Part0 = lCharacter.HumanoidRootPart
	weld.Part1 = rootPart
	weld.Parent = lCharacter.HumanoidRootPart
	localCharacter = lCharacter
end
2 Likes

I’ve had problems with welds before. No idea if this will solve it, but try parenting the weld before changing the properties of it.

1 Like

That didn’t solve it :confused: I also tried to swap Part0, Part1 and the Parent and I got excited as it worked the first three times I started a server and tested, then the 4th the same thing happened!! :face_with_symbols_over_mouth:

I would just tween the HumanoidRootPart’s CFrame to the CFrame of the server side HumanoidRootPart every 0.1 seconds, but I’m not sure if that would be more efficient than a weld.

1 Like

Ohhhh I see what you’re doing - this is exactly what I was doing a few weeks ago with my enemy system and it had some strange replication issues. It’s more than likely because it’s to do with Humanoids in the server side character. Making the local character a separate object (not joined by welds) might be your best bet, but I don’t know. If you do find out why this happens or a good solution, please post it on here because I think this could help me too.

But yeah tweening every .1 seconds sounds like it would fix the replication. Not sure if it’s efficient though.

1 Like

I’ve already tested tweening and it worked perfectly fine, but I’m worried it might not be nearly as efficient as a weld.

If someone knows let me know how efficient a tween would be compared to a weld :slight_smile:

Yeah, that’d be the problem. Are you more concerned about performance issues because of the tweening, or because of updating every .1 seconds?

I’m pretty sure most games on Roblox that use custom characters update them several times a second - I think I heard Phantom Forces updates theirs 12 times per second. Maybe instead of TweenService, you could just lerp them because then you can control how smooth it is, but I don’t know which is more efficient. Do some tests and see how it does, I guess.

1 Like

I’m concerned about performance issues because of the tweening and isn’t tweening just more advanced lerping?

When I want to animate a joint, I usually use Motor6D and then TweenService on its Transform property.

1 Like

I don’t think this topic is about animations, it’s more about custom character replication.
Also @vsnry, I’ve recently used TweenService for animating a projectile, and it works fine. It’s using a bezier curve and it goes to several points along a path but works without lag. Use TweenService for now - you can always change it later.

2 Likes

Mind swapping the weld’s Part0 and Part1 property and setting the parent of the weld to rootPart?

Already tried that as stated in one of my replies.

1 Like

Try waiting a short time after the character spawns before welding the local character?

Already do that, I tried everything I could think of :thinking:

I do not understand why this doesn’t work… I just tried Motor6D’s and they behaved exactly the same way, I don’t know what to do any more as I can’t CFrame the characters since I need the .Touched behaviour to work on the body parts.

Could you try using a WeldConstraint?

Another alternative is to create an Attachment, AlignPosition, and AlignOrientation into the new character. Setting these constraints to rigidly align the new character to the old character should do the trick.

You could also set it so that the game does not use :LoadCharacter() or AutoLoadCharacter and do a custom character. You can do this by having the server set the Player.Character to a model with a HumanoidRootPart brick and Humanoid in it, then have the client build the character around the new character on CharacterAdded.

-- Server
local nc = Instance.new("Model")
local hrp = Instance.new("Part", nc)
hrp.Size = Vector3.new(2,2,1)
hrp.Name = "HumanoidRootPart"
hrp.Transparency = 1
local hum = Instance.new("Humanoid", nc)


game.Players.PlayerAdded:Connect(function(p)
	wait(1)
	local x = nc:Clone()
	x.Parent = workspace
	x.HumanoidRootPart:SetNetworkOwner(p)
	p.Character = x
end)


-- client
game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
	print(char.HumanoidRootPart, char.Humanoid)
end)

You can do this by having the server set the Player.Character to a model with a HumanoidRootPart brick and Humanoid in it, then have the client build the character around the new character on CharacterAdded.

That is exactly what I’m doing, except the character doesn’t work if there is no head and when I weld the custom character locally the position stops replicating. I will try your “AlignPosition and AlignOrientation” method tomorrow and see how it goes!

So AlignPosition and AlignOrientation worked fine, until I tried to teleport the character by setting the CFrame to a different place and then it ended up glitching out like the rest of the welds and stuff I tried. I guess the only way to make this work properly is just to tween CFrame…

You didn’t use Model:SetPrimaryPartCFrame(cframe) ?