I made a ragdoll module that i want to use for a combat game, Whenever someone dies, they ragdoll just fine, But when they get knocked back, their limbs goes through the floor, Despite using the same module script
Ragdoll is fine in this video, ignore that it stands up
In this video, the limbs are clipping
Module Script Of Ragdoll
local ragdoll = {}
ragdoll.__Index = ragdoll
function ragdoll:newragdoll(character)
local colconstraint1 = Instance.new("NoCollisionConstraint")
colconstraint1.Parent = character["Left Leg"]
colconstraint1.Part0 = colconstraint1.Parent
colconstraint1.Part1 = character.Torso
colconstraint1.Enabled = true
local colconstraint2 = Instance.new("NoCollisionConstraint")
colconstraint2.Parent = character["Right Leg"]
colconstraint2.Part0 = colconstraint2.Parent
colconstraint2.Part1 = character.Torso
colconstraint2.Enabled = true
local raycastparams = RaycastParams.new()
raycastparams.FilterDescendantsInstances = {character}
raycastparams.FilterType = Enum.RaycastFilterType.Exclude
--velocity.VectorVelocity = Vector3.new(1,-10,0)
character["Left Arm"].CanCollide = true
character["Right Arm"].CanCollide = true
character.Humanoid.PlatformStand = true
for _,joint in pairs(character:GetDescendants()) do
if joint:IsA("Motor6D") and joint.Parent ~= character then
--if joint:FindFirstAncestor("Accessories") then return end
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
--joint.Parent.CanCollide = true
joint:Destroy()
end
end
end
return ragdoll
Module script of my combat where it calls the ragdoll (I do other stuff in this script but this is the important one as it detects hitbox too)
elseif State == "Hit" then
local hitsound = game.ServerStorage.Audio.Hit:Clone()
hitsound.Parent = Hit
hitsound:Play()
local classinfo = BF:Invoke(Character)
if
math.floor((Character.HumanoidRootPart.Position - Humanoid.Parent.HumanoidRootPart.Position).Magnitude)
<= 6
then
Humanoid:TakeDamage(classinfo.Damage)
if not Character.Values.Stun.Value then
stun(Humanoid, 1)
end
if Character.Values.Combo.Value == 4 then
print(Humanoid.Parent)
ragdollmodule:newragdoll(Humanoid.Parent) -- CALLING THE RAGDOLL
knockback(Humanoid, Character,40,0.2)
end
end
hitsound.Ended:Wait()
hitsound:Destroy()
Client side Of Ragdoll
local humanoid = game.Players.LocalPlayer.Character.Humanoid
humanoid.Died:Once(function()
humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
end)
Please let me know what im doing wrong