Need help with pickup system physics

Recently, I’ve made a pickup system, but I’ve noticed that weird glitches have been going on such as the picked up player walking as well as my character being tilt a bit as if there was weight to the other character.

Here’s my code:

--// Settings
local function PickupPlayer(Player, Target)
	local Character = Player.Character
	local Root = Character.HumanoidRootPart
	
	local TargetRoot = Target.HumanoidRootPart
	TargetRoot.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(1.5,1.5,0) * CFrame.Angles(math.rad(20),0,0)
	for _, v in pairs(Target:GetChildren()) do
		if v:IsA("BasePart") then
			v.Massless = true
		end
	end
	
	PHYSICS.setCollisionGroup(Target, "Uncollide")
		
	local Weld = Instance.new("WeldConstraint")
	Weld.Name = "Carry"
	Weld.Part0 = Root
	Weld.Part1 = TargetRoot
	Weld.Parent = Root
end

local function DropPickedup(Player)
	local Character = Player.Character
	
	if Character.HumanoidRootPart:FindFirstChild("Carry") then
		local Target = Character.HumanoidRootPart.Carry.Part1.Parent
		PHYSICS.setCollisionGroup(Target, "Humanoid")
		
		for _, v in pairs(Target:GetChildren()) do
			if v:IsA("BasePart") then
				v.Massless = false
			end
		end
		
		Players:GetPlayerFromCharacter(Target).States.Pickedup.Value = false
		Character.HumanoidRootPart.Carry:Destroy()
	end
end

Here’s what it looks visually:
https://gyazo.com/e2f08df441b1b7e979110ed970bac277

https://gyazo.com/1e8a1a9f99a39ac84c0797686195b3e8

It seems like the entire character is lighter (maybe because I’ve set the target to massless). I believe the issue may be regarding the root part because of me using a weld constraint but I’m not sure.

3 Likes

Still need help with this issue, please let me know if any more information is needed. I need this problem solved as soon as possible. Sorry for the mini bump

The other client has network ownership of their character, so setting their parts to massless on the server could be a bit finicky.

Also, try setting the picked up player’s humanoid state to Physics

Thanks for the state change tip! It still seems like there is weight to the other client. Is there anything I could do about it? Could I set the network ownership to the server temporarily?

Would making the other client’s character massless on their client help the situation?

I would try using a combination of remote events and local scripts to make the picked up character massless on their own client.

I’ve noticed that Massless does not replicate to the server for the character. The issue of the weight still appears. I will see if I could temporarily give network ownership to the server.

Issue has been solved; all I had to do was make the target that’s picked up not able to collide with anything else. The tilt is just a odd weld constraint glitch. Thanks for everything.

2 Likes