Welding character to another character

I’m trying to make it so when Player1 presses E, it welds Player2 to them. Problems I am having are

  1. Player1 presses E and is teleported to Player2
  2. Player1 is frozen while Player2 is still able to freely move around

    Player1 should be allowed to move around, and when they move Player2 should be attached to them. There seems to be no attachment at all atm
local function InputBegan(input, GPE)
	if GPE then return end
	
	if input.KeyCode == Enum.KeyCode.E then
		-- Create weld
		local Weld = Instance.new('Weld')
		Weld.Parent = workspace['Player1']
		Weld.Part0 = workspace['Player2'].HumanoidRootPart
		Weld.Part1 = workspace['Player1'].HumanoidRootPart
		
		-- Make carried character unanchored
		for _, v in pairs(workspace['Player2']:GetDescendants()) do
			if v:IsA('Part') or v:IsA('UnionOperation') or v:IsA('MeshPart') then
				v.Anchored = false
			end
		end
		
	end
end

game:GetService('UserInputService').InputBegan:Connect(InputBegan)

Carry system.rbxl (19.5 KB)
This is all the code in the place

3 Likes

As far as I know Part0 is the main Part and Part1 is the attached Part. Try switching them.

Yup, try shifting the players in the function. And about the freezing. Try to set the player to a state, like Sitting = true or maybe PlatformStanding = true

2 Likes

Switching them didn’t produce any difference in results :confused:

Are you sure the script is running in Player1 and not Player2?

I don’t think this is a good approach to making a carry system.

Since you are welding it from the client, other clients won’t experience the weld and they can move freely.

Maybe welding it server-side can help?

2 Likes

Doing it on client won’t work because the network ownership, try it on server instead, using remote events / functions.

This may not help at the moment, but I read in another post that you could attach parts to you if the parts were massless. Try to loop through the other character’s body to make their parts massless.

Another thing you could do is disable all of the motor6D joints. I don’t particularly know if that will work, but it will stop someone from moving.

I use this and works fine… just adapt it for ur needs
EDIT: I made a mistake… welp Im not testing it, but yeah xD I guess I fixed it :v

local ps = game:GetService("PhysicsService")
ps:CreateCollisionGroup("colG")
ps:CollisionGroupSetCollidable("colG","colG",false)

local function weldPlayers(holder, bag)
	local holderPlayer = holder.Character.Head
	local bagPlayer = bag.Character.PrimaryPart
	
	bag.Character.Humanoid.PlatformStand = true
	
	local weld = Instance.new("Weld")
	weld.Name = "bagWeld"
	weld.Part0 = bagPlayer
	weld.Part1 = holderPlayer
	weld.C1 = CFrame.new(0, 3, 0) -- Change it to offset the bag player :v
	weld.Parent = bagPlayer
	
	-- Cancel Collisions
	for _,v in pairs(bag.Character:GetChildren()) do
		if v:IsA("BasePart") then
			ps:SetPartCollisionGroup(v,"colG")
			v.Massless=true -- Make the bad massless
		end
	end
	
	for _,v in pairs(holder.Character:GetChildren()) do
		if v:IsA("BasePart") then
			ps:SetPartCollisionGroup(v,"colG")
		end
	end
end
weldPlayers("holder player", "bag player") -- Add ur players as u wish
3 Likes

Part0 and Part1 has no difference. Whether it’s swapped or not, there will be no actual difference.

How can I reverse the process then??

The same way u did it on ur script.

Iterate in both player’s Childrens, find the “Weld” and Destroy()
Set the Character.Humanoid.Platform = false
and Iterate until find their BasePart and set Massless = false, and CollisionGroupId = 0

1 Like

You have to do this for both players, except the Massless

local function unWeldPlayers(plr)
	plr.Character.Humanoid.PlatformStand = false
	local weld2Del = plr.Character.PrimaryPart:FindFirstChild("bagWeld")
	weld2Del:Destroy()
	
	for _, v in pairs(plr.Character:GetChildren()) do
		if v:IsA("BasePart") then
			v.CollisionGroupId = 0
			v.Massless = false
		end
	end
end
unWeldPlayers("desired player")
2 Likes

A problem I just noticed with this tho is it breaks my player-player collisions. I am using this code to prevent players from colliding

Because I don’t want them to collide ever

Yup.
This line
v.CollisionGroupId = 0
is setting ur player’s CollisionGroup to the Default CollisionGroup. If u are using custom Groups, you need to change the id number to the one that u are using to manage ur CollisionGroups in ur game

Actually, notice that in the start of the script, we’re creating a collision group to handle both players to not collide, if you are already using custom groups just change those lines to whatever u need in ur game :3

2 Likes