Gun welding differs from client to server?

Hello y’all, I’ve been making a gun, and to keep the parts of the gun together I am using a weld-constraint for each part. All’s well until I actually use it in the game. The welds are all screwed up as shown here:

whereas if I pause the game and move to the server, rearrange to what the player would be seeing, the welds are totally normal like they should be, as seen here:

Anyone know what is going on?

Weld Constraints are used to weld parts together in place. This is fine for the client where you can accurately predict the position, but unfortunately on the server there’s almost always some type of delay that causes the parts to get messed up. What I usually do to solve this is use Manual Welds instead and set the C0 to match the offset. That way it will always be consistent.

Here’s a function you can use to weld a model together with Manual Welds:

local function WeldModel(model)
	for _, part in pairs(model:GetDescendants()) do
		if part:IsA("BasePart") then
			local weld ="ManualWeld")
			weld.Part0 = model.PrimaryPart
			weld.Part1 = part
			weld.C0 = model.PrimaryPart.CFrame:inverse()
			weld.C1 = part.CFrame:inverse()
			weld.Parent = model.PrimaryPart

I removed all weld constraints, binded the function to when the tool is equipped, and replaced “model” with “tool” (which is script.Parent, the tool object) and it gives me this error:
attempt to index nil with ‘GetDescendants’
Which doesn’t make sense, since the variable tool works in the rest of the script. Do you happen to know a fix?

EDIT: I fixed that part, I forgot that the scripts were under a folder called “Scripts”, but now it is detecting the variable tool as the mouse? It’s giving me the error:
GetDescendents is not a valid member of Mouse

Weird that its returning nil, but just a heads up this function requires “model” to be a Model because it uses PrimaryPart as the basis for welding. If these models are being loaded in from replicated storage, I’d recommend running this function in the command bar or something so that way you don’t even have to worry about welding the model together when you equip.