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
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)