How to do knockback using a tool like in Slap Battles

Hello developers, :wave:

I want to figure out how to deal knockback on a player but similar to Slap Battles’ knockback system. I’ve been looking around for solutions, however nothing works I tried using BodyVelocity but it still didn’t work and I don’t understand how to make the properties work so it makes the character experience knockback.

Thanks!

Can we see your script? It will let me see what is wrong with your bodyvelocity

Anything in the toolbox? Might give you a good start.

Usually with knockback, they use a sudden huge force and delete the force a fraction of a second later. You can use bodyvelocity.

create velocity > set velocity to high numbers > wait 0.2 seconds > delete velocity > player go flying back a bit

try BasePart:ApplyImpulse(Vector3)
it applies a 1 time force to the part

You’re most likely using R6. If you want to implement a ragdoll system consider this one:
Ragdoll 5.2.rbxm (7.8 KB)
I made a game similar to this one and I used a temporary LinearVelocity object that was destroyed 0.2 seconds later. The only issue with LinearVelocity is that it doesn’t replicate the physics immediately, so you will need to implement a system that counteracts this issue or use BodyVelocity.

or just use apply impulse
seriously why do people make instances for constant force for a short burst when apply impulse was made for this

Replication lag can cause issues with ApplyImpulse and it might not work right if changing network owners.

The specific reason why I did it is to remain in compatibility of an older system I made that used BodyVelocity.

1 Like

I tried looking on the toolbox, but all of them don’t work for some reason.

1 Like

Show your code so far when developing the knockback system, or add it into your original post.

local glove = script.Parent.Parent.Glove
local hand = script.Parent.Hand
local slap = script.Parent.Slap
local playerslapped = game.ReplicatedStorage:WaitForChild("PlayerSlapped")

playerslapped.OnServerEvent:Connect(function(player, targetedplayer, humanoid, locatedhead)
	slap:Play()
	local targetHumanoid = targetedplayer:WaitForChild("HumanoidRootPart")
	local playerHumanoid = player.Character:WaitForChild("HumanoidRootPart")
	if targetHumanoid and playerHumanoid then
		for _, v in pairs(targetedplayer:GetDescendants()) do
			if v:IsA("Motor6D") then
				local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
				a0.CFrame = v.C0
				a1.CFrame = v.C1
				a0.Parent = v.Part0
				a1.Parent = v.Part1

				v.Part0.CanCollide = true
				v.Part1.CanCollide = true

				local b = Instance.new("BallSocketConstraint")
				b.Attachment0 = a0
				b.Attachment1 = a1
				b.Parent = v.Part0

				v.Enabled = false
			end
		end
		local force = Instance.new("LinearVelocity", targetHumanoid)
		force.MaxForce = Vector3.new(2,1.5,2) * math.huge
		local direction = (targetHumanoid.CFrame.Position - playerHumanoid.CFrame.Position).Unit
		force.VectorVelocity = (direction + Vector3.new(0,0.5,0)).Unit * 25

		local rotation = Instance.new("BodyAngularVelocity",targetHumanoid)
		rotation.AngularVelocity = Vector3.new(1,0.7,1) * math.pi * math.random(1.9,2.9)
		rotation.MaxTorque = Vector3.new(1.5,1.5,1.5) * math.huge
		rotation.P = 3600
		
		wait(0.35)

	end
	targetedplayer.HumanoidRootPart.CanCollide = false
end)

Most of these were copied

local velocity = Instance.new("BodyVelocity",hit.Parent.HumanoidRootPart)
		velocity.MaxForce = Vector3.new(3,3,3) * math.huge
		local dir = (hit.Parent.HumanoidRootPart.CFrame.Position - script.Parent.Parent.HumanoidRootPart.Position).Unit
		velocity.Velocity = (dir + Vector3.new(0,1,0)).Unit *script.Parent.Configuration.Power.Value

		local rot = Instance.new("BodyAngularVelocity",hit.Parent.HumanoidRootPart)
		rot.AngularVelocity = Vector3.new(1,2,1) * math.pi *5
		rot.MaxTorque = Vector3.new(2,5,2) *math.huge
		rot.P = 5000

		game:GetService("Debris"):AddItem(velocity, 0.5)
		game:GetService("Debris"):AddItem(rot,0.5)
		wait(0.8)
1 Like

It works, but how do I make the targeted character ragdoll?

Nevermind, I figured it out, thank you!

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