How to Make a Knockback Script Consistently Make You Land On Your Back?

Basically, I have a knockback script as well as a ragdoll script. Whenever an enemy player gets hit with a weapon, the knockback and ragdoll will activate on that enemy player.

Whenever the player is getting knocked back, there’s a chance the enemy player lands on its feet, and that makes the ragdoll weird.

In order to fix it, I’ve tried making the CFrame of the enemy players humanoid root part face the sky, but it didn’t work.

Here’s my knockback code.

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 * 0.8
game.Debris:AddItem(force, .25)
local rot = Instance.new("BodyAngularVelocity", eHrp)
rot.AngularVelocity = Vector3.new(1, 1, 1) * math.pi * 0.2
rot.MaxTorque = Vector3.new(1, 1, 1) * math.huge
rot.P = 10000
game.Debris:AddItem(rot, .25)
4 Likes

It seems like to me you need to just wait a second after the player lands before allowing them to get back up.

2 Likes

When the ragdoll ends, that is the part where the player gets back up, so that won’t work.

1 Like

The problem is not in the knockback script it’s in the ragdoll some solutions are enabling platformStanding (a Humanoid proprety) or create another local script fire a remoteEvent when you ragdoll the player and disable the GettingUP humanoidState and set the humanoidState to physics in the local script

1 Like

The problem is, platform stand makes the enemy player’s limbs clip into the ground, and the same with the physics state.

1 Like

Can you show me the ragdoll script ?

1 Like

In the server script you should have the ragdoll event when you want to ragdoll a player fire this event to the player that’s going to be ragdolled and pass the player that’s going to ragdolled i’m going to call playerTarget event:FireClient(playerTarget,"Ragdoll") you also need to pass a string to know if we’re going to ragdoll the player or not

Then on the local script you should do this

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ragdollEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("ModuleEvents"):WaitForChild("Ragdoll")

ragdollEvent.OnClientEvent:Connect(function(context)
	local player = game.Players.LocalPlayer
	local character = player.Character or player.CharacterAdded:Wait() -- You need to put this inside of the onClientEvent so as to get the new character that gets added after the player dies if we don't do this then if the player dies this script won't work
	local humanoid :Humanoid = character:WaitForChild("Humanoid")
	
	if context == "Ragdoll" then
		humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
		humanoid:ChangeState(Enum.HumanoidStateType.Physics)
	elseif context == "UnRagdoll" then
		humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,true)
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Running,true)
		humanoid:ChangeState(Enum.HumanoidStateType.GettingUp) -- we change the state to getting up well to make the player get up 
	end
end)
2 Likes

Do I make the event a Remote Event?

1 Like

Yes a remoteEvent (placeHolder i can’t post this message if i don’t type more than so i’m just typing anything)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.