So I am rying to create a grab script but, the character model after grabbing another character behaves weird, I tried creating a Collisiongroup inorder to stop collision but Im not sure
local Grant = script.Parent:WaitForChild("Grant")
local Debris = game:GetService("Debris")
local Physic = game:GetService('PhysicsService')
local HandCollision = "Hands"
Grant.OnServerEvent:Connect(function(player)
local character = player.Character
local humanoid = character:FindFirstChildOfClass("Humanoid")
local Hitbox = Instance.new("Part")
Debris:AddItem(Hitbox,1)
Hitbox.Color = Color3.new(1,0,0)
Hitbox.CanCollide = false
Hitbox.Anchored = true
Hitbox.Transparency = .5
Hitbox.Size = character.PrimaryPart.Size
Hitbox.CFrame = character.PrimaryPart.CFrame * CFrame.new(0,-humanoid.HipHeight,-character.PrimaryPart.Size.Z * 1.5)
Hitbox.Parent = game:GetService("Workspace")
local OnHit
OnHit = Hitbox.Touched:Connect(function(touch)
if touch:FindFirstAncestorWhichIsA("Model") then
print('Model')
local Model = touch:FindFirstAncestorOfClass("Model")
if Model ~= character then
if Model:FindFirstChildOfClass("Humanoid",true) then
print('Humanoid')
for _,v in ipairs(character:GetDescendants()) do
if v:IsA("BasePart") then
Physic:SetPartCollisionGroup(v,HandCollision)
end
end
for _,v in ipairs(Model:GetDescendants()) do
if v:IsA("BasePart") then
Physic:SetPartCollisionGroup(v,HandCollision)
end
end
local Humanoid = Model:FindFirstChildOfClass("Humanoid",true)
Humanoid.PlatformStand = false
local Grabbed = Instance.new("Motor6D",character.RightHand)
Grabbed.Part0 = character.RightHand
Grabbed.Part1 = Model.UpperTorso
Grabbed.C0 = CFrame.new(0,-character.RightHand.Size.Y +character.RightHand.Size.Y/2 ,0)
end
end
end
end)
end)