Hello, im trying to do a knockback/pushback when the player is ragdolled on the 4th hit, but im not sure if im using the wrong method to push the player back or not, right now im using HumanoidRootPart.Velocity = direction * force
here is what it looks like in game
https://gyazo.com/9a6b7222e7d7fa3a4e1d54096ebb5a42
and this is the script part of the knockback
local function HandleHit(hit)
local enemyCharacter = hit.Parent
if enemyCharacter and enemyCharacter ~= character then
local enemyHumanoid = enemyCharacter:FindFirstChild("Humanoid")
local ragdollTrigger = enemyCharacter:FindFirstChild("RagdollTrigger")
local enemyRootPart = enemyCharacter:FindFirstChild("HumanoidRootPart")
local playerRootPart = character:FindFirstChild("HumanoidRootPart")
if enemyHumanoid and enemyRootPart and playerRootPart then
-- Prevent multiple hits on the same enemy using a debounce
if hitDebounce[enemyCharacter] then return end
hitDebounce[enemyCharacter] = true
-- Skip if the enemy is already ragdolled
if ragdollTrigger and ragdollTrigger.Value then
return
end
-- Apply damage
enemyHumanoid:TakeDamage(DAMAGE)
-- Apply knockback and ragdoll only on the 4th swing
if swingIndex == 4 then
-- Calculate knockback direction
local direction = (enemyRootPart.Position - playerRootPart.Position).Unit
enemyRootPart.Velocity = direction * KNOCKBACK_FORCE
-- Apply ragdoll
if ragdollTrigger then
ragdollTrigger.Value = true
-- Reset ragdoll after a short delay
task.delay(1, function()
ragdollTrigger.Value = false
end)
end
end
-- Clear the debounce after HIT_DEBOUNCE_TIME
task.delay(HIT_DEBOUNCE_TIME, function()
hitDebounce[enemyCharacter] = nil
end)
end
end
end