Problem with CollisionGroups

I made a player carrying system and it works well except for one thing the character carrying the carried player collides with the character and it just goes crazy.

I have tried everything nothing seems wrong but for some reason it won’t work.

			maid[player.Name.."CarryPrompt"] = CarryPrompt.Triggered:Connect(function(playerWhoTriggered)
				local PlayerWhoTriggeredCharacter = playerWhoTriggered.Character
				local PlayerWhoTriggeredHumanoidRootPart = PlayerWhoTriggeredCharacter:WaitForChild("HumanoidRootPart", 10)
				
				if IsCarrying.Value == false then
					IsCarrying.Value = true
					
					RevivePrompt.Enabled = false
					
					CarryPrompt.ActionText = "Uncarry "..player.Name

					for _, v in pairs(Players:GetPlayers()) do
						if v.Name ~= playerWhoTriggered.Name then
							CarryEvent:FireClient(v, CarryPrompt)
						end
					end
					
					for _, v in pairs(character:GetChildren()) do
						if v:IsA("BasePart") then
							v.Massless = true
							v.CollisionGroup = "NoCollision"
						end
					end
					
					local CarryAttachment0 = PlayerWhoTriggeredHumanoidRootPart:WaitForChild("RootAttachment", 10):Clone()
					CarryAttachment0.Name = "CarryAttachment0"
					CarryAttachment0.Position = Vector3.new(0, 0, 0.5)
					CarryAttachment0.Parent = PlayerWhoTriggeredHumanoidRootPart
					
					local CarryPosition = Instance.new("AlignPosition")
					CarryPosition.Name = "CarryPosition"
					CarryPosition.Mode = Enum.PositionAlignmentMode.TwoAttachment
					CarryPosition.ApplyAtCenterOfMass = false
					CarryPosition.Attachment0 = RootAttachment
					CarryPosition.Attachment1 = CarryAttachment0
					CarryPosition.MaxForce = math.huge
					CarryPosition.Responsiveness = 200
					CarryPosition.Parent = humanoidRootPart
				else
					--This isn't done yet
				end
			end)
PhysicsService:RegisterCollisionGroup("NoCollision")
PhysicsService:RegisterCollisionGroup("Players")

PhysicsService:CollisionGroupSetCollidable("NoCollision", "NoCollision", false)
PhysicsService:CollisionGroupSetCollidable("Players", "Players", false)

Any type of help is appreciated.

Try using these,

local PhysicsService = game:GetService("PhysicsService")
PhysicsService:RegisterCollisionGroup("PlayerCollisons")
PhysicsService:CollisionGroupSetCollidable("PlayerCollisons", "PlayerCollisons", false)

local function disableCollisions(character)
    for _, bodyPart in pairs(character:GetChildren()) do
        if bodyPart:IsA("BasePart") then
            bodyPart.CollisionGroup = "PlayerCollisons"
        end
    end
end

local function enableCollisions(character: Model)
    for _, bodyPart: BasePart in pairs(character:GetChildren()) do
        if bodyPart:IsA("BasePart") then
            bodyPart.CollisionGroup = "Default"
        end
    end
end
1 Like

Screenshot 2024-02-26 104343

Doesn’t work.

That’s interesting, try setting the network ownership of the Target to the Player and when you’re finished carrying with them set it back to the server (nil)

local function disableCollisions(character)
    for _, bodyPart in pairs(character:GetDescendants()) do
        if bodyPart:IsA("BasePart") then
            bodyPart.CollisionGroup = "PlayerCollisons"
            bodyPart:SetNetworkOwner(player)
        end
    end
end

local function enableCollisions(character: Model)
    for _, bodyPart in pairs(character:GetDescendants()) do
        if bodyPart:IsA("BasePart") then
            bodyPart.CollisionGroup = "Default"
               bodyPart:SetNetworkOwner(nil)
        end
    end
end

I think I know the problem when the player ragdolls these collider parts are created.

I am specifically using this ragdoll module right here:
[Updated] Perfect R6 Ragdoll - Easiest Ragdoll System for R6 Avatars - Resources / Community Resources - Developer Forum | Roblox

I will see if I can make these collider parts non-collidable and see from there.

I have solved this earlier, but I was busy and couldn’t respond but here I am.

What I did was change this line:

PhysicsService:CollisionGroupSetCollidable("PlayerCollisons", "PlayerCollisons", false)

To:

PhysicsService:CollisionGroupSetCollidable("PlayerCollisons", "Default", false)

And then made the rest of the carrying system.

The AlignPosition was lagging behind so I had to create a heartbeat to constantly set the network ownership of the carried players BodyParts to the player carrying them so it doesn’t lag, but it works great.

(I made sure to handle the collisions before handling the player being carried)

2 Likes

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