hello im trying to make a carry system but i cant seem to find out the cause of this bug. carrying the player seems to mess with the player is carrying physics and makes the player thats holding a player not able to move. ive tried every thing but nothing seems to work. please help me.
– see video here
External Media– code
local physicsService = game:GetService("PhysicsService")
local PickUpEvent = game:GetService("ReplicatedStorage"):WaitForChild("mechanics"):WaitForChild("PickUpPlayer"):WaitForChild("pickUpPlayerEvent")
physicsService:RegisterCollisionGroup("pickUp")
physicsService:CollisionGroupSetCollidable("pickUp", "pickUp", false)
PickUpEvent.OnServerEvent:Connect(function(player, holder, held, instruction)
local heldHumanoid = held:FindFirstChild("Humanoid")
local holdHumanoid = holder:FindFirstChild("Humanoid")
local heAnimation = script.HeldAnimation
local hoAnimation = script.HoldAnimation
local heldAnimation = heldHumanoid:LoadAnimation(heAnimation)
local holdAnimation = heldHumanoid:LoadAnimation(hoAnimation)
if instruction == "hold" then
local holderAttach = Instance.new("Attachment")
local heldAttach = Instance.new("Attachment")
heldAttach.CFrame = CFrame.new(-2,-2,0)
holderAttach.Parent = holder.HumanoidRootPart
heldAttach.Parent = held.HumanoidRootPart
heldHumanoid.PlatformStand = true
local allignPos = Instance.new("AlignPosition")
allignPos.Name = "holdingPos"
allignPos.RigidityEnabled = true
allignPos.ReactionForceEnabled = false
allignPos.Attachment0 = holderAttach
allignPos.Attachment1 = heldAttach
allignPos.Enabled = true
allignPos.Parent = holder.HumanoidRootPart
local allignOri = Instance.new("AlignOrientation")
allignOri.Name = "holdingOri"
allignOri.RigidityEnabled = true
allignPos.ReactionForceEnabled = false
allignOri.Attachment0 = holderAttach
allignOri.Attachment1 = heldAttach
allignOri.Enabled = true
allignOri.Parent = holder.Torso
holdAnimation:Play()
heldAnimation:Play()
for _, v in pairs(held:GetChildren()) do
if v:IsA("BasePart") then
v.CollisionGroup = "pickUp"
v.Massless = true
v:SetNetworkOwner(holder)
end
end
for _, v in pairs(holder:GetChildren()) do
if v:IsA("BasePart") then
v.CollisionGroup = "pickUp"
end
end
end
if instruction == "drop" then
local allignPos = holder:FindFirstChild("holdingPos")
if allignPos then
allignPos:Destroy()
end
local allignOri = holder:FindFirstChild("holdingOri")
if allignOri then
allignOri:Destroy()
end
heldAnimation:Stop()
holdAnimation:Stop()
heldHumanoid.PlatformStand = false
for _, v in pairs(held:GetChildren()) do
if v:IsA("BasePart") then
v.CollisionGroupId = 0
v.Massless = false
v:SetNetworkOwner(nil)
end
end
for _, v in pairs(holder:GetChildren()) do
if v:IsA("BasePart") then
v.CollisionGroupId = 0
end
end
end
end)