Hi. I am currently working on a carry system which allows alive players to carry dead players. I discovered a glitch where the carrier dies when picking up the dead player. However, after testing this in a local server of 2 people, it seems to only effect 1 player?
Test results from 2 player local server:
Weld killing the player
Weld not killing the other player
Function
local function weldPlayers(origin,carry)
local ro,rc=origin.Character,carry.Character
carry.Character.Humanoid.PlatformStand=true
local Weld = Instance.new('WeldConstraint', ro)
Weld.Name = 'CarryWeld'
Weld.Part0 = rc.Torso
Weld.Part1 = ro.Torso
--Weld.C0 = CFrame.new(0,0,-1)
for _,v in pairs(carry.Character:GetChildren()) do
if v:IsA("BasePart") then
PS:SetPartCollisionGroup(v,"nocol")
v.Massless=true
end
end
for _,v in pairs(origin.Character:GetChildren()) do
if v:IsA("BasePart") then
PS:SetPartCollisionGroup(v,"nocol")
end
end
end
FULL SCRIPT (excuse unefficient scripting)
game.ReplicatedStorage.Events.Remotes.Carry.OnServerEvent:Connect(function(p)
local char = p.Character
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = char:GetDescendants()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(char.HumanoidRootPart.Position, Vector3.new(0, -4, 0), raycastParams)
if raycastResult and raycastResult.Instance.Parent:FindFirstChildOfClass("Humanoid") and raycastResult.Instance.Parent:FindFirstChild("CombatStates").KnockedState.Value then -- detect if player is infact knocked/dead
print(raycastResult.Instance.Parent)
for i,v in pairs(raycastResult.Instance.Parent:GetDescendants()) do --unragdoll dead player
if v:IsA("BallSocketConstraint") then
v.UpperAngle = 0
v.TwistUpperAngle = 0
v.TwistLowerAngle = 0
local Joints = Instance.new("Motor6D",v.Parent)
Joints.Part0 = v.Attachment0.Parent
Joints.Part1 = v.Attachment1.Parent
Joints.C0 = v.Attachment0.CFrame
Joints.C1 = v.Attachment1.CFrame
v:Destroy()
end
end
raycastResult.Instance.Parent.Humanoid.Sit = false
raycastResult.Instance.Parent.HumanoidRootPart.Position = char.HumanoidRootPart.Position
raycastResult.Instance.Parent.Humanoid.Animator:LoadAnimation(carryAnimInstance):Play()
weldPlayers(p, game.Players:GetPlayerFromCharacter(raycastResult.Instance.Parent)) -- weld dead player to p.Character
end
end)