So i made a script where a player slaps another player then the player that is slapped gets ragdolled. Everything is working fine no errors but when the Ragdoll Function executes on a player this happens:
Ragdoll Script:
local function RagdollCharacter(Char)
local d = Char:GetDescendants()
for i=1,#d do
local desc = d[i]
if desc:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local part0 = desc.Part0
local joint_name = desc.Name
local attachment0 = desc.Parent:FindFirstChild(joint_name.."Attachment") or desc.Parent:FindFirstChild(joint_name.."RigAttachment")
local attachment1 = part0:FindFirstChild(joint_name.."Attachment") or part0:FindFirstChild(joint_name.."RigAttachment")
if attachment0 and attachment1 then
socket.Attachment0, socket.Attachment1 = attachment0, attachment1
socket.Parent = desc.Parent
desc:Destroy()
end
end
end
end
Since i also want the player to be knocked back by the slap it would help alot if someone to guide me on how to do that, but the Main priority is the Ragdoll script thanks!!
Okay so, I looked at the function, and I messed around with it for a bit and I discovered that it only works if you also kill the Humanoid.
If that isn’t a viable option, I can go make a new script.
Also, for the knocking back of the slap, try doing this:
Get the LookVector of the character who was hit
Use :ApplyImpulse on the character’s HumanoidRootPart with the opposite of the character’s LookVector
It should look something like this:
local function ApplyImpulse(character)
local HumanoidRootPart = character.HumanoidRootPart
HumanoidRootPart:ApplyImpulse(-HumanoidRootPart.CFrame.LookVector * 2000)
end
If you don’t need to un-ragdoll them after, try this:
local function RagdollCharacter(character)
local Humanoid = character.Humanoid
Humanoid.WalkSpeed = 0
for i, descendant in ipairs(character:GetDescendants()) do
if descendant:IsA("Motor6D") then
local a1 = Instance.new("Attachment")
a1.CFrame = descendant.C0
a1.Parent = descendant.Part0
local a2 = Instance.new("Attachment")
a2.CFrame = descendant.C1
a2.Parent = descendant.Part1
local socket = Instance.new("BallSocketConstraint")
socket.Attachment0 = a1
socket.Attachment1 = a2
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
socket.Parent = descendant.Parent
descendant:Destroy()
end
end
end
I recommend you if you are ragdolling the character put on the script Humanoid:ChangeState() to Physics to give the character a better ragdoll for example
So basically I want the player who’s been slapped to rag doll to then UNragdoll I want the whole server to see it so that’s why I’m doing on a server scriot
local CharacterMotor6Ds = {}
local function RagdollCharacter(character)
local Humanoid = character.Humanoid
Humanoid.PlatformStand = true
CharacterMotor6Ds[character] = {}
for i, descendant in ipairs(character:GetDescendants()) do
if descendant:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local part0 = descendant.Part0
local joint_name = descendant.Name
local attachment0 = descendant.Parent:FindFirstChild(joint_name.."Attachment") or descendant.Parent:FindFirstChild(joint_name.."RigAttachment")
local attachment1 = part0:FindFirstChild(joint_name.."Attachment") or part0:FindFirstChild(joint_name.."RigAttachment")
if attachment0 and attachment1 then
socket.Attachment0, socket.Attachment1 = attachment0, attachment1
socket.Parent = descendant.Parent
table.insert(CharacterMotor6Ds[character], descendant)
descendant.Enabled = false
end
end
end
end
local function UnragdollCharacter(character)
local Humanoid = character.Humanoid
Humanoid.PlatformStand = false
local characterMotor6Ds = CharacterMotor6Ds[character]
for i, motor6D in ipairs(characterMotor6Ds) do
motor6D.Enabled = true
end
end
local function UnragdollCharacter(character)
local HumanoidRootPart = character.HumanoidRootPart
HumanoidRootPart.Anchored = true
local characterMotor6Ds = CharacterMotor6Ds[character]
for i, motor6D in ipairs(characterMotor6Ds) do
motor6D.Enabled = true
end
local Humanoid = character.Humanoid
Humanoid.PlatformStand = false
task.wait(0.1)
HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
HumanoidRootPart.Anchored = false
end