Grab System Using Align Position And Align Rotation

Ive been trying to get a Proper Player Grab System using Align Position and Align Rotation The Issue is it dosent really do what its supposed to do it just glitches the player that gets grabbed but it worked fine when i tested it on 2 dummys without any code

My code:


function module.Grab2(Character,Enemy,Attachment1,Attachment0,C1,Time) 

local alignPOS = Instance.new("AlignPosition")
	local alignROT = Instance.new("AlignOrientation")


Enemy.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame * C1
task.wait()
alignPOS.Attachment0 = Attachment0
alignPOS.Attachment1  = Attachment1
alignROT.Attachment0 = Attachment0
alignROT.Attachment1 = Attachment1
alignPOS.RigidityEnabled = true
alignROT.RigidityEnabled = true
alignPOS.Parent = Character
alignROT.Parent = Character


debris:AddItem(alignPOS,Time)
debris:AddItem(alignROT,Time)

	

end
1 Like

This is likely due to conflicts between the character’s existing physics and the alignment constraints.

local RunService = game:GetService("RunService")
local debris = game:GetService("Debris")

function module.Grab2(Character, Enemy, Attachment1, Attachment0, C1, Time)
    -- Disable character physics
    local humanoid = Enemy:FindFirstChildOfClass("Humanoid")
    if humanoid then
        humanoid:ChangeState(Enum.HumanoidStateType.Physics)
    end

    -- Set initial position
    Enemy.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame * C1
    
    -- Create alignment objects
    local alignPOS = Instance.new("AlignPosition")
    local alignROT = Instance.new("AlignOrientation")
    
    -- Configure AlignPosition
    alignPOS.Attachment0 = Attachment0
    alignPOS.Attachment1 = Attachment1
    alignPOS.RigidityEnabled = true
    alignPOS.ReactionForceEnabled = false
    alignPOS.ResponsivenessFactor = 65  -- Adjust as needed
    alignPOS.MaxForce = 1e6  -- Adjust as needed
    
    -- Configure AlignOrientation
    alignROT.Attachment0 = Attachment0
    alignROT.Attachment1 = Attachment1
    alignROT.RigidityEnabled = true
    alignROT.ReactionTorqueEnabled = false
    alignROT.ResponsivenessFactor = 65  -- Adjust as needed
    alignROT.MaxTorque = 1e6  -- Adjust as needed
    
    -- Parent alignment objects
    alignPOS.Parent = Character
    alignROT.Parent = Character
    
    -- Use RunService to update position smoothly
    local connection
    connection = RunService.Heartbeat:Connect(function()
        if not Character:IsDescendantOf(game.Workspace) or not Enemy:IsDescendantOf(game.Workspace) then
            connection:Disconnect()
            return
        end
        
        Enemy.HumanoidRootPart.Velocity = Vector3.new(0, 0, 0)
        Enemy.HumanoidRootPart.RotVelocity = Vector3.new(0, 0, 0)
    end)
    
    -- Clean up
    debris:AddItem(alignPOS, Time)
    debris:AddItem(alignROT, Time)
    
    task.delay(Time, function()
        connection:Disconnect()
        if humanoid then
            humanoid:ChangeState(Enum.HumanoidStateType.Running)
        end
    end)
end

that didnt fix anything Maybe there would be a better way of handling the grab but im not sure

1 Like

Off topic a bit but are you making a battle Ground game? I’ve noticed you’ve been in fighting type themed posts as of late

I see, can you provide more information about your game set up? it might help.

im working on 2 games one of them is battlegrounds + im new to roblox so im trying to learn the engine

I ended up modifying the code but it still has some issues outside of theg rab itself like it messes up with ragdoll and sometimes makes the playerwho grabs be launched into the void

Modified code: `function module.Grab2(Character, Enemy, Part0,Part1,C0, C1, Time)
– Disable character physics
local humanoid = Enemy:FindFirstChildOfClass(“Humanoid”)
if humanoid then
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
end

Enemy.HumanoidRootPart.Massless = true
for i,v in Enemy:GetChildren() do
	if not v:IsA("BasePart") then continue end
	v.CollisionGroup = "Attached"
	
end
for i,v in Character:GetChildren() do
	if not v:IsA("BasePart") then continue end

	v.CollisionGroup = "Attacher"

end
-- Set initial position
Enemy.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame * C1

-- Create alignment objects
local alignPOS = Instance.new("Motor6D")


-- Configure AlignPosition
alignPOS.Part0 = Part0
alignPOS.Part1 = Part1
alignPOS.C1 = C1


-- Configure AlignOrientation

-- Parent alignment objects
alignPOS.Parent = Character

-- Use RunService to update position smoothly
local connection
connection = RunService.Heartbeat:Connect(function()
	if not Character:IsDescendantOf(game.Workspace) or not Enemy:IsDescendantOf(game.Workspace) then
		connection:Disconnect()
		return
	end

	Enemy.HumanoidRootPart.Velocity = Vector3.new(0, 0, 0)
	Enemy.HumanoidRootPart.RotVelocity = Vector3.new(0, 0, 0)
end)

-- Clean up
debris:AddItem(alignPOS, Time)

task.delay(Time, function()
	for i,v in Enemy:GetChildren() do
		if not v:IsA("BasePart") then continue end

v.CollisionGroup = “default”

	end
	for i,v in Character:GetChildren() do
		if not v:IsA("BasePart") then continue end
		v.CollisionGroup = "default"

	end
	connection:Disconnect()
	Enemy.HumanoidRootPart.Massless = false

	if humanoid then
		humanoid:ChangeState(Enum.HumanoidStateType.PlatformStanding)
	end
end)

end` the game is r6