-
What do you want to achieve?
Whenever an enemy character (eChar) is hit, I want it to ragdoll with knockback (like its arms waving around when it is in air). I already have the knockback ready. -
What is the issue?
I have tried many ragdoll modules and scripts but can’t find one that works. Most of them use a certain key to ragdoll or just ragdolling on death. I’m decently new to using Roblox Studio, so I don’t know how to configure those scripts to when the enemy character is hit. I know the Motor6Ds should be replaced with BallSocketConstraints, but I don’t know how to replace them after the ragdolling is done. -
What solutions have you tried so far?
I have tried almost everything I could find on the forums.
Here’s my code for when eChar is hit.
Tool.Handle.Touched:Connect(function(hit)
if not debounce then
return
end
debounce = true
if hit.Parent:FindFirstChild("Humanoid") then
local eChar = hit.Parent
local pChar = Tool.Parent
local eHrt = eChar:FindFirstChild("HumanoidRootPart")
local pHrt = pChar:FindFirstChild("HumanoidRootPart")
local fightUtils = require(game.ServerScriptService.fightUtils)
if pHrt and eHrt then
wait(0.1)
script.Parent.Configuration.Slap:Play()
script.Disabled = true
--Where I want the Ragdoll
fightUtils:knockBack(pChar, eChar)
local ParticlesEffect = HIT_EFFECT_HANDLER.new(
eHrt,
game.ServerStorage.Effects.Particles,
1,
1
)
ParticlesEffect:GenerateParticles()
--Where I want Ragdoll End
end
wait(script.Parent.Configuration.Speed.Value)
debounce = false
script.Disabled = false
end
end)
Here’s the “FightUtils” module (does the knockback).
local fightUtils = {}
function fightUtils:knockBack(pChar, eChar)
if pChar and eChar then
local pHrp = pChar:FindFirstChild("HumanoidRootPart")
local eHrp = eChar:FindFirstChild("HumanoidRootPart")
local power = game.StarterPack.Default.Configuration.Power.Value
if pHrp and eHrp then
local force = Instance.new("BodyVelocity", eHrp)
force.MaxForce = Vector3.new(1, 1, 1) * math.huge
local dir = (eHrp.CFrame.Position - pHrp.CFrame.Position).Unit
force.Velocity = (dir + Vector3.new(0, 0.7, 0)). Unit * power * 8
game.Debris:AddItem(force, .25)
local rot = Instance.new("BodyAngularVelocity", eHrp)
rot.AngularVelocity = Vector3.new(1, 1, 1) * math.pi * 2.5
rot.MaxTorque = Vector3.new(1, 1, 1) * math.huge
rot.P = 10000
game.Debris:AddItem(rot, .25)
end
end
end
return fightUtils