Player position doesn't replicate if welded to part

What do you want to achieve? I want player to move with certain part when HumanoidRootPart welded to it.

What is the issue? Player position stops replicating to server when HumanoidRootPart welded.

I was making ledge climbing system and using welds to hook player to the ledge, so player can grab ledges of moving objects. When I almost finished, I noticed that player on server had wrong position and didn’t follow the part (player hooked to that
transparent part).

Client and server sides before part was moved:
Client


Server
Screenshot2

Client and server sides after part was moved:
Client


Server

As you can see player on server positioned higher than on client, because when moved down and weld was added the position didn’t replicate. After part was moved player on server kept the same position.

Here’s the weld settings (also the weld is created on client and exists only there):

Also the weld is created on client and exists only there and if I handle weld creation in server script nothing changes.

2 Likes

With the information I have, here are my best assumptions:

There is an attachment who's position is only changed in the client

If you used an attachment, make sure to set the position of said attachment on the server as well, otherwise it will default to the humanoid root part position.

The weld position is updating on only the client

You are changing the weld position (or whatever is handling the player movement) on the client exclusively

Other notes: It looks like the server is attaching to the HumanoidRootPart(primarypart of the character model)

Note that I do not have much expertise in this subject, so some of these claims may be invalid.

2 Likes

Yes, the weld is updating only on client, but it exists only there, as it created via local script. I also tried creating weld via server script, but it didn’t change anything.
The C1 offset stays allways the same, it works fine on client, player’s position just doesn’t replicate to server like it replicates when simply changing PrimaryPart’s CFrame.

I thought weld should’ve update PrimaryPart’s CFrame, but it doesn’t replicate to server while if CFrame changed manually (not by weld) it does.

(also weld doesnt use attachments, C0 and C1 is set manually)

1 Like

use remote events and show your script swell

2 Likes

This is all the code that controls the weld:

local initialCFrame = rootPart.CFrame
		
local weld = Instance.new("Weld")
weld.Name = ""
weld.C0 = CFrame.identity
weld.C1 = anchorPart.CFrame:ToObjectSpace(initialCFrame):Inverse()
weld.Part0 = anchorPart
weld.Part1 = rootPart
weld.Parent = rootPart

But I don’t understand, what is the purpose of using remote events here?

1 Like

What I noticed while testing, player doesn’t replicate position to server if PrimaryPart is anchored. Looks like welds just ‘anchor’ the part and change their CFrame, therefore position isn’t replicated.
This could be a bug, but if this is intended, there should be some method that forces the CFrame to replicate when anchored, right?

2 Likes

Anchored parts are not physically simulated. When you anchor the PrimaryPart (or weld it to another anchored part), Player no longer have control over it. A simple solution is keep it unanchored and hold PrimaryPart’s position by using AlignPosition + AlignOrientation, Or update it’s position every frame on client using RunService

2 Likes

AlignPosition and AlignOrientation doesn’t actually ‘hook’ player to part, it just pulls player towards it which causes some collision issues of other parts is on the way.

Constantly updating player’s position on client didn’t work, as it doesn’t replicate if RootPart is anchored, but when it isn’t, because of network delay, on server player will be affected by gravity each frame server doesn’t receive position data and teleported back up each time it does.

But if anchor player on server and update position there it works fine, however I’m not sure if server won’t lag if there’s like 10 players hooked to moving parts each.

Sorry i have my instructions unclear, Those solutions only work if the part were unanchored. Also constantly updating player’s position on client always works, Since the server never simulates a part unless it didn’t have a NetworkOwner.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.