This only appears to be happening for the 2nd player who joins and i have no idea why
code:
script.Parent.Grab.OnServerEvent:Connect(function(player)
local HB = game.ReplicatedStorage.HitboxesAndParts.DefaultHitbox
local HBClone = HB:Clone()
HBClone.Parent = game.Workspace
HBClone.Position = player.Character.HumanoidRootPart.Position
local ManualWeld = Instance.new("ManualWeld")
ManualWeld.Parent = HBClone
ManualWeld.Part0 = player.Character.HumanoidRootPart
ManualWeld.Part1 = HBClone
ManualWeld.C0 = CFrame.new(0,0,-2.8)
HBClone.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("IsGrabbable") then
if hit.Parent:FindFirstChild("IsGrabbable").Value ~= player.Character.IsGrabbable.Value then
HeldPLayer = hit.Parent
HBClone.CanTouch = false
for _,part in pairs(HeldPLayer:GetDescendants()) do
-- GetDescendants
if part:IsA("BasePart") then
if part.Name == "Torso" then
part.CanCollide = false
else
part.CanCollide = false
end
end
end
local GrabWeld = Instance.new("ManualWeld")
GrabWeld.Parent = player.Character.PosWeld
GrabWeld.Part1 = HeldPLayer.HumanoidRootPart
GrabWeld.Part0 = player.Character.PosWeld
for _, v in pairs(HeldPLayer:GetDescendants()) do --ragdoll
if v:IsA("Motor6D") then
local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
a0.CFrame = v.C0
a1.CFrame = v.C1
a0.Parent = v.Part0
a1.Parent = v.Part1
local b = Instance.new("BallSocketConstraint")
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = v.Part0
v.Enabled = false
end
end
wait(5)
for _,part in pairs(HeldPLayer:GetDescendants()) do
-- GetDescendants
if part:IsA("BasePart") then
if part.Name == "Torso" then
else
part.CanCollide = true
end
end
end
if GrabWeld then
GrabWeld:Destroy()
end
for _,v in pairs(HeldPLayer:GetDescendants()) do --unragdoll
if v:IsA('Motor6D') then
v.Enabled = true
end
if v.Name == 'BallSocketConstraint' then
v:Destroy()
end
if v.Name == 'Attachment' then
v:Destroy()
end
end
end
end
end)
end)
Any solution?